{"record":{"id":"afba4f85e3c4e1c9","repo":"BerriAI/litellm","slug":"authentication-failed-check-your-arize-phoenix-ap","errorCode":null,"errorMessage":"Authentication failed. Check your Arize Phoenix API key and permissions.","messagePattern":"Authentication failed\\. Check your Arize Phoenix API key and permissions\\.","errorType":"exception","errorClass":"Exception","httpStatus":401,"severity":"error","filePath":"litellm/integrations/arize/arize_phoenix_client.py","lineNumber":88,"sourceCode":"            # Use the underlying httpx client directly to avoid query param extraction\n            response = self.http_handler.get(url, headers=self.headers)\n            response.raise_for_status()\n\n            data: Final = response.json()\n            return data.get(\"data\")\n\n        except Exception as e:\n            # Check if it's an HTTP error\n            response = getattr(e, \"response\", None)\n            if response is not None and hasattr(response, \"status_code\"):\n                if response.status_code == 404:\n                    return None\n                elif response.status_code == 403:\n                    raise Exception(\n                        f\"Access denied to prompt version '{prompt_version_id}'. Check your Arize Phoenix permissions.\"\n                    )\n                elif response.status_code == 401:\n                    raise Exception(\"Authentication failed. Check your Arize Phoenix API key and permissions.\")\n                else:\n                    raise Exception(f\"Failed to fetch prompt version '{prompt_version_id}': {e}\")\n            else:\n                raise Exception(f\"Error fetching prompt version '{prompt_version_id}': {e}\")\n\n    def test_connection(self) -> bool:\n        \"\"\"\n        Test the connection to the Arize Phoenix API.\n\n        Returns:\n            True if connection is successful, False otherwise\n        \"\"\"\n        try:\n            # Try to access the prompt_versions endpoint to test connection\n            url: Final = f\"{self.api_base}/prompt_versions\"\n            response: Final = self.http_handler.client.get(url, headers=self.headers)\n            response.raise_for_status()\n            return True","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/arize/arize_phoenix_client.py#L70-L106","documentation":"ArizePhoenixClient.get_prompt_version converts HTTP 401 into this Exception: the Bearer token was rejected — missing, malformed, expired, or simply not a valid Phoenix API key. Note the client always sends Authorization: Bearer <api_key>, so any non-empty but wrong key lands here rather than failing earlier.","triggerScenarios":"Calling get_prompt_version (directly or via the litellm prompt manager loading a prompt) with an incorrect, revoked, or expired PHOENIX_API_KEY. 404 maps to None and 403 to the permissions error; 401 reaches this branch.","commonSituations":"Using an OTLP export header value or Phoenix UI session token instead of an API key; key deleted/rotated in Phoenix while the old one is still deployed; whitespace/newline accidentally included in the env var value.","solutions":["Regenerate the API key in Phoenix (Settings -> API Keys) and update PHOENIX_API_KEY / the api_key param","Strip whitespace: `export PHOENIX_API_KEY=$(printf '%s' \"$PHOENIX_API_KEY\")` or check for trailing newline in CI secrets","Confirm you are using a Phoenix API key, not a collector/OTLP header or a different product's key"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import httpx, os\n\nresp = httpx.get(\n    f\"{api_base}/prompt_versions/{prompt_version_id}\",\n    headers={\"Authorization\": f\"Bearer {os.environ['PHOENIX_API_KEY']}\"},\n    timeout=5,\n)\nif resp.status_code == 401:\n    raise SystemExit(\"PHOENIX_API_KEY rejected (401) — regenerate the key in Phoenix settings\")","typeGuard":null,"tryCatchPattern":"try:\n    manager.compile(prompt_id=prompt_id, prompt_variables=vars)\nexcept Exception as e:\n    if \"Authentication failed\" in str(e):\n        raise SystemExit(\"Invalid PHOENIX_API_KEY — check for stale/rotated key or stray whitespace\") from e\n    raise","preventionTips":["After rotating Phoenix keys, update every deployment that references them in the same change","Trim env var values in CI/CD to avoid trailing newline auth failures"],"tags":["arize-phoenix","authentication","http-401","api-key","prompts"],"backgroundTag":"http-401-unauthorized","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}