{"record":{"id":"e0a214702674600e","repo":"BerriAI/litellm","slug":"fireworks-api-key-is-not-set-please-set-firework","errorCode":null,"errorMessage":"FIREWORKS_API_KEY is not set. Please set 'FIREWORKS_API_KEY' or 'FIREWORKS_AI_API_KEY' in your environment","messagePattern":"FIREWORKS_API_KEY is not set\\. Please set 'FIREWORKS_API_KEY' or 'FIREWORKS_AI_API_KEY' in your environment","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"litellm/llms/fireworks_ai/rerank/transformation.py","lineNumber":108,"sourceCode":"            # Silently ignore max_chunks_per_doc as Fireworks AI doesn't support it\n            pass\n\n        if max_tokens_per_doc is not None:\n            # Silently ignore max_tokens_per_doc as Fireworks AI doesn't support it\n            pass\n\n        return params\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        api_key: str | None = None,\n        optional_params: dict | None = None,\n    ) -> dict:\n        api_key = self._get_api_key(api_key)\n        if api_key is None:\n            raise ValueError(\n                \"FIREWORKS_API_KEY is not set. Please set 'FIREWORKS_API_KEY' or 'FIREWORKS_AI_API_KEY' in your environment\"\n            )\n\n        default_headers: Final = {\n            \"Authorization\": f\"Bearer {api_key}\",\n            \"Content-Type\": \"application/json\",\n        }\n\n        # If 'Authorization' is provided in headers, it overrides the default.\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        # Merge other headers, overriding any default ones except Authorization\n        return {**default_headers, **headers}\n\n    def transform_rerank_request(\n        self,\n        model: str,","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/fireworks_ai/rerank/transformation.py#L90-L126","documentation":"The Fireworks rerank transformation validates the environment before proxying a rerank request. It looks for an explicit api_key, then FIREWORKS_API_KEY, then FIREWORKS_AI_API_KEY; when none resolves it raises this ValueError naming both accepted env vars. This is the rerank-specific analogue of the chat key check.","triggerScenarios":"Calling litellm.rerank(model='fireworks_ai/...', query=..., documents=[...]) without api_key and without FIREWORKS_API_KEY / FIREWORKS_AI_API_KEY exported.","commonSituations":"Rerank added to an existing app after chat was configured, but only the chat path was tested; router/proxy config that supplies keys for completion models but not rerank models; local run where the env var lives only in the server's shell.","solutions":["Export FIREWORKS_API_KEY (or FIREWORKS_AI_API_KEY) in the process that executes rerank.","Pass api_key explicitly on the rerank call or configure it on the litellm Router/model entry used for rerank.","If using litellm proxy, add the key to the rerank model's litellm_params in config.yaml."],"exampleFix":"# before\nresults = litellm.rerank(model=\"fireworks_ai/fireworks/qwen3-reranker-8b\", query=\"what is litellm\", documents=[\"litellm is a sdk\"])\n\n# after\nresults = litellm.rerank(\n    model=\"fireworks_ai/fireworks/qwen3-reranker-8b\",\n    query=\"what is litellm\",\n    documents=[\"litellm is a sdk\"],\n    api_key=os.environ[\"FIREWORKS_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef validate_fireworks_rerank_env() -> None:\n    if not (os.getenv(\"FIREWORKS_API_KEY\") or os.getenv(\"FIREWORKS_AI_API_KEY\")):\n        raise RuntimeError(\"Rerank needs FIREWORKS_API_KEY or FIREWORKS_AI_API_KEY\")","typeGuard":null,"tryCatchPattern":"try:\n    litellm.rerank(model=\"fireworks_ai/fireworks/qwen3-reranker-8b\", query=q, documents=docs)\nexcept ValueError as e:\n    if \"FIREWORKS_API_KEY is not set\" in str(e):\n        raise RuntimeError(\"Configure rerank credentials\") from e\n    raise","preventionTips":["In the litellm proxy, put the key in the rerank model's litellm_params so env leakage can't break it.","Use the same credential bootstrap for chat and rerank paths — one function, both checked.","Add a rerank integration test to CI, not just completion tests."],"tags":["fireworks-ai","rerank","authentication","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}