{"record":{"id":"5cc306e1d820c330","repo":"BerriAI/litellm","slug":"fireworks-api-key-is-not-set-5cc306","errorCode":null,"errorMessage":"FIREWORKS_API_KEY is not set","messagePattern":"FIREWORKS_API_KEY is not set","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"litellm/llms/fireworks_ai/common_utils.py","lineNumber":65,"sourceCode":"            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        return dynamic_api_key\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        api_key = self._get_api_key(api_key)\n        if api_key is None:\n            raise ValueError(\"FIREWORKS_API_KEY is not set\")\n\n        auth_headers: Final = {\"Authorization\": f\"Bearer {api_key}\", **headers}\n        content_type_header: Final = (\n            {} if any(key.lower() == \"content-type\" for key in auth_headers) else {\"Content-Type\": \"application/json\"}\n        )\n        return self._add_session_affinity_header({**auth_headers, **content_type_header}, litellm_params)\n\n    def _add_session_affinity_header(self, headers: dict, litellm_params: dict) -> dict:\n        if any(key.lower() == \"x-session-affinity\" for key in headers):\n            return headers\n        session_id: Final = get_fireworks_session_id(litellm_params)\n        if not session_id:\n            return headers\n        return {**headers, \"x-session-affinity\": session_id}\n","sourceCodeStart":47,"sourceCodeEnd":80,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/fireworks_ai/common_utils.py#L47-L80","documentation":"FireworksAIConfig.validate_environment() runs on every Fireworks chat/Completion request to build auth headers. It resolves the key from the explicit api_key argument, then FIREWORKS_API_KEY, then FIREWORKS_AI_API_KEY; if all are None it raises 'FIREWORKS_API_KEY is not set' before any network call is made.","triggerScenarios":"Calling litellm.completion(model='fireworks_ai/...', messages=[...]) with neither api_key= passed nor FIREWORKS_API_KEY / FIREWORKS_AI_API_KEY present in the environment (or set to an empty string).","commonSituations":"New integration where the env var was forgotten; .env file not loaded in the deployed environment; variable renamed during a provider migration; secret cleared in CI for a supposedly mocked test.","solutions":["Set FIREWORKS_API_KEY (or the legacy alias FIREWORKS_AI_API_KEY) in the runtime environment.","Or pass the key per call: litellm.completion(model='fireworks_ai/...', api_key='fw_...', ...).","Check the value is non-empty (get_secret_str returns None for ''), e.g. print(bool(os.getenv('FIREWORKS_API_KEY'))) in the failing context."],"exampleFix":"# before\nresponse = litellm.completion(model=\"fireworks_ai/accounts/fireworks/models/llama-v3p1-8b-instruct\", messages=[{\"role\": \"user\", \"content\": \"hi\"}])\n\n# after\nresponse = litellm.completion(\n    model=\"fireworks_ai/accounts/fireworks/models/llama-v3p1-8b-instruct\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    api_key=os.environ[\"FIREWORKS_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef get_fireworks_key() -> str:\n    key = os.getenv(\"FIREWORKS_API_KEY\") or os.getenv(\"FIREWORKS_AI_API_KEY\")\n    if not key:\n        raise RuntimeError(\"Set FIREWORKS_API_KEY before using fireworks_ai models\")\n    return key\n\n# call before any completion\nkey = get_fireworks_key()","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"fireworks_ai/...\", messages=msgs)\nexcept ValueError as e:\n    if \"FIREWORKS_API_KEY is not set\" in str(e):\n        raise RuntimeError(\"Fireworks credentials missing in deployment\") from e\n    raise","preventionTips":["Fail fast at startup: resolve and validate all provider keys before accepting requests.","Pass api_key explicitly per call in multi-tenant apps instead of relying on process env.","Smoke-test one Fireworks completion in CI to catch missing credentials before production."],"tags":["fireworks-ai","authentication","configuration","environment-variables"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}