{"record":{"id":"5a54d4a2092ead66","repo":"BerriAI/litellm","slug":"api-key-is-required","errorCode":null,"errorMessage":"api_key is required","messagePattern":"api_key is required","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/arize/arize_phoenix_client.py","lineNumber":42,"sourceCode":"    Supports:\n    - Authentication with Bearer tokens\n    - Fetching prompt versions\n    - Direct API base URL configuration\n    \"\"\"\n\n    def __init__(self, api_key: str | None = None, api_base: str | None = None):\n        \"\"\"\n        Initialize the Arize Phoenix client.\n\n        Args:\n            api_key: Arize Phoenix API token\n            api_base: Base URL for the Arize Phoenix API (e.g., 'https://app.phoenix.arize.com/s/workspace/v1')\n        \"\"\"\n        self.api_key = api_key\n        self.api_base = api_base\n\n        if not self.api_key:\n            raise ValueError(\"api_key is required\")\n\n        if not self.api_base:\n            raise ValueError(\"api_base is required\")\n\n        # Set up authentication headers\n        self.headers = {\n            \"Authorization\": f\"Bearer {self.api_key}\",\n            \"Accept\": \"application/json\",\n        }\n\n        # Initialize HTTPHandler\n        self.http_handler = HTTPHandler(disable_default_headers=True)\n\n    def get_prompt_version(self, prompt_version_id: str) -> dict[str, Any] | None:\n        \"\"\"\n        Fetch a prompt version from Arize Phoenix.\n\n        Args:","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/arize/arize_phoenix_client.py#L24-L60","documentation":"ArizePhoenixClient is the HTTP client the prompt integration uses to fetch prompt versions from the Phoenix API. Its constructor requires a truthy api_key; it is used immediately to build the 'Authorization: Bearer <key>' header, so an empty/None key cannot be deferred. Missing key fails fast at construction.","triggerScenarios":"Instantiating ArizePhoenixClient(api_key=None) or api_key='' — typically indirectly when prompt_initializer found no api_key in litellm_params and PHOENIX_API_KEY was unset, or when the prompt manager is constructed directly in tests.","commonSituations":"Local Phoenix deployments where the developer assumed auth-free access (the client requires a key even for localhost); empty-string env var (PHOENIX_API_KEY=\"\") which is falsy; passing the key under a different parameter name.","solutions":["Supply the Phoenix API key: set PHOENIX_API_KEY or pass api_key explicitly where the client is constructed","For local Phoenix, generate/retrieve an API key from the Phoenix UI settings and use it — the client always sends Bearer auth","Check for empty-string env vars: `if not os.getenv('PHOENIX_API_KEY'): raise` early in your startup with a clearer message"],"exampleFix":"# before\nclient = ArizePhoenixClient(api_base=\"http://localhost:6006\")  # api_key=None -> ValueError\n\n# after\nclient = ArizePhoenixClient(\n    api_key=os.environ[\"PHOENIX_API_KEY\"],\n    api_base=\"http://localhost:6006\",\n)","handlingStrategy":"validation","validationCode":"import os\n\napi_key = os.getenv(\"PHOENIX_API_KEY\")\nif not api_key:\n    raise SystemExit(\"PHOENIX_API_KEY missing/empty — required even for local Phoenix\")\nclient = ArizePhoenixClient(api_key=api_key, api_base=\"http://localhost:6006\")","typeGuard":"def has_phoenix_key(api_key: str | None) -> bool:\n    return bool(api_key and api_key.strip())","tryCatchPattern":"try:\n    ArizePhoenixClient(api_key=api_key, api_base=api_base)\nexcept ValueError as e:\n    if \"api_key is required\" in str(e):\n        raise SystemExit(\"Set PHOENIX_API_KEY (create one in Phoenix Settings → API Keys; required even locally)\") from e\n    raise","preventionTips":["Note the Phoenix client always requires a key, including local deployments — create a local key up front","Fail fast at startup on empty/whitespace env values, since empty strings are falsy and trigger this too"],"tags":["arize-phoenix","api-key","authentication","constructor-validation"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}