BerriAI/litellm · error · ValueError

api_key must be provided for Vantage destination (set…

Error message

api_key must be provided for Vantage destination (set VANTAGE_API_KEY env var or pass in destination_config)

What it means

FocusVantageDestination.__init__ raises this ValueError when the config dict for uploading FOCUS CSV exports to the Vantage cost-import API has no api_key. The factory resolves api_key from explicit overrides or the VANTAGE_API_KEY environment variable, so hitting this means neither source produced a value. The api_key authenticates calls to https://api.vantage.sh.

Solutions

  1. Export VANTAGE_API_KEY in the proxy's environment: export VANTAGE_API_KEY=<your key>.
  2. Pass api_key directly in destination_config overrides: {'api_key': '...', 'integration_token': '...'}. Note integration_token is also required (a separate error is raised if it's missing).
  3. Check for empty-string values — only truthy values pass the check.
  4. Confirm the destination type is spelled 'vantage'; a typo can route to a different factory path.

Example fix

# before (shell)
# VANTAGE_API_KEY not set, config only has integration_token

# after
export VANTAGE_API_KEY="vt_..."
export VANTAGE_INTEGRATION_TOKEN="it_..."
Defensive patterns

Strategy: validation

Validate before calling

import os

api_key = overrides.get('api_key') or os.getenv('VANTAGE_API_KEY')
if not api_key:
    raise SystemExit('VANTAGE_API_KEY (or api_key override) is required for Vantage FOCUS exports')

Type guard

def has_vantage_api_key(config: dict) -> bool:
    return bool(config.get('api_key') or os.getenv('VANTAGE_API_KEY'))

Prevention

When it happens

Trigger: Configuring destination_type='vantage' for FOCUS exports with VANTAGE_API_KEY unset and no api_key override; running the proxy in a shell/deployment where the env var was never exported; passing an empty-string api_key in destination_config.

Common situations: CI or container deployments where secrets are injected via a vault but the variable name doesn't match VANTAGE_API_KEY; rotating keys and briefly having an empty value; copying a config template that only included the integration token.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/a3104cce8c37df03. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/focus/destinations/vantage_destination.py:103

        writer.writerow([row[i] for i in keep_indices])

    return output.getvalue().encode("utf-8")


class FocusVantageDestination(FocusDestination):
    """Upload FOCUS CSV exports to the Vantage cost-import API."""

    def __init__(
        self,
        *,
        prefix: str,
        config: dict[str, Any] | None = None,
    ) -> None:
        config = config or {}
        api_key: Final = config.get("api_key")
        integration_token: Final = config.get("integration_token")
        if not api_key:
            raise ValueError(
                "api_key must be provided for Vantage destination "
                "(set VANTAGE_API_KEY env var or pass in destination_config)"
            )
        if not integration_token:
            raise ValueError(
                "integration_token must be provided for Vantage destination "
                "(set VANTAGE_INTEGRATION_TOKEN env var or pass in destination_config)"
            )
        self.api_key = api_key
        self.integration_token = integration_token
        self.base_url = config.get("base_url", "https://api.vantage.sh")
        self.prefix = prefix

    async def deliver(
        self,
        *,
        content: bytes,
        time_window: FocusTimeWindow,

View on GitHub (pinned to 77b7c6c40c)