{"record":{"id":"833d1439753cee58","repo":"BerriAI/litellm","slug":"failed-to-fetch-models-from-fireworks-ai-status-c","errorCode":null,"errorMessage":"Failed to fetch models from Fireworks AI. Status code: {response.status_code}, Response: {response.json()}","messagePattern":"Failed to fetch models from Fireworks AI\\. Status code: (.+?), Response: (.+?)","errorType":"http","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/fireworks_ai/chat/transformation.py","lineNumber":782,"sourceCode":"            raise ValueError(\n                \"FIREWORKS_API_BASE or FIREWORKS_API_KEY is not set. Please set the environment variable, to query Fireworks AI's `/models` endpoint.\"\n            )\n\n        account_id: Final = get_secret_str(\"FIREWORKS_ACCOUNT_ID\")\n        if account_id is None:\n            raise ValueError(\n                \"FIREWORKS_ACCOUNT_ID is not set. Please set the environment variable, to query Fireworks AI's `/models` endpoint.\"\n            )\n\n        base = api_base.rstrip(\"/\")\n        base = base.removesuffix(\"/v1\")\n        response: Final = litellm.module_level_client.get(\n            url=f\"{base}/v1/accounts/{account_id}/models\",\n            headers={\"Authorization\": f\"Bearer {api_key}\"},\n        )\n\n        if response.status_code != 200:\n            raise ValueError(\n                f\"Failed to fetch models from Fireworks AI. Status code: {response.status_code}, Response: {response.json()}\"\n            )\n\n        models: Final = response.json()[\"models\"]\n\n        return [\"fireworks_ai/\" + model[\"name\"] for model in models]\n\n    @staticmethod\n    def get_api_key(api_key: str | None = None) -> str | None:\n        return api_key or (\n            get_secret_str(\"FIREWORKS_API_KEY\")\n            or get_secret_str(\"FIREWORKS_AI_API_KEY\")\n            or get_secret_str(\"FIREWORKSAI_API_KEY\")\n            or get_secret_str(\"FIREWORKS_AI_TOKEN\")\n        )\n\n\nclass FireworksAIChatCompletionStreamingHandler(OpenAIChatCompletionStreamingHandler):","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/fireworks_ai/chat/transformation.py#L764-L800","documentation":"FireworksAIConfig.get_models() performs a GET to {api_base}/v1/accounts/{account_id}/models with a Bearer token. Any non-200 status code (401/403 bad key, 404 wrong account id, 429 rate limit, 5xx) triggers this ValueError, embedding the HTTP status and the parsed JSON body from Fireworks in the message for diagnosis.","triggerScenarios":"FIREWORKS_API_KEY is invalid/revoked; FIREWORKS_ACCOUNT_ID does not belong to that key's workspace; hitting Fireworks rate limits; a transient 5xx from the models endpoint.","commonSituations":"Rotated API key but stale value in the environment; copy-pasted account id from the wrong Fireworks project; periodic model-refresh jobs that start failing after a quota change or key expiry.","solutions":["Read the embedded status/body: 401/403 means fix FIREWORKS_API_KEY; 404 means FIREWORKS_ACCOUNT_ID is wrong for that key; 429 means back off and retry.","Verify the pair (key, account id) with a direct curl: curl -H \"Authorization: Bearer $FIREWORKS_API_KEY\" https://api.fireworks.ai/v1/accounts/$FIREWORKS_ACCOUNT_ID/models.","Wrap model listing in retry-with-backoff for 429/5xx responses so transient Fireworks incidents do not crash startup."],"exampleFix":"# before\nmodels = litellm.get_model_list('fireworks_ai')  # crashes on any non-200\n\n# after\nimport time\nfor attempt in range(3):\n    try:\n        models = litellm.get_model_list('fireworks_ai')\n        break\n    except ValueError as e:\n        if 'Status code: 429' in str(e) or 'Status code: 5' in str(e):\n            time.sleep(2 ** attempt)\n        else:\n            raise","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"import re, time\n\ndef list_fireworks_models():\n    for attempt in range(4):\n        try:\n            return litellm.get_model_list(\"fireworks_ai\")\n        except ValueError as e:\n            msg = str(e)\n            if \"Status code: 429\" in msg or re.search(r\"Status code: 5\\\\d\\\\d\", msg):\n                time.sleep(2 ** attempt)\n                continue\n            raise  # 401/403/404 are configuration bugs, not retryable\n    raise RuntimeError(\"Fireworks /models unavailable after retries\")","preventionTips":["Cache the model list with a TTL instead of calling /models on every request.","Alert on repeated 401/403 — it means the key or account id is stale, not the network.","Run the curl equivalent in your deploy pipeline to validate the (key, account_id) pair before rollout."],"tags":["fireworks-ai","http","model-listing","api-errors"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}