{"record":{"id":"68115b97477350dc","repo":"BerriAI/litellm","slug":"missing-api-key-make-sure-you-pass-in-your-api-ke","errorCode":null,"errorMessage":"Missing api_key, make sure you pass in your api key","messagePattern":"Missing api_key, make sure you pass in your api key","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/llms/bytez/chat/transformation.py","lineNumber":138,"sourceCode":"        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        headers.update(\n            {\n                \"content-type\": \"application/json\",\n                \"Authorization\": f\"Key {api_key}\",\n                \"user-agent\": f\"litellm/{version}\",\n            }\n        )\n\n        if not messages:\n            raise Exception(\"kwarg `messages` must be an array of messages that follow the openai chat standard\")\n\n        if not api_key:\n            raise Exception(\"Missing api_key, make sure you pass in your api key\")\n\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        encoded_model: Final = encode_url_path_segments(model, field_name=\"model\")\n        return f\"{API_BASE}/{encoded_model}\"\n\n    def transform_request(\n        self,\n        model: str,","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bytez/chat/transformation.py#L120-L156","documentation":"In Bytez's validate_environment, after headers are built it checks the resolved api_key argument; if falsy it raises this generic Exception. The Authorization header would otherwise read 'Key None'. Unlike other providers it does not fall back to an env var here — the key must arrive via the api_key argument (litellm resolves env-based keys before this point).","triggerScenarios":"Calling litellm.completion(model=\"bytez/...\", messages=msgs) with no api_key and no BYTEZ_API_KEY available for litellm to auto-resolve; passing api_key=None explicitly; proxy model entry missing the api_key field.","commonSituations":"First call to a newly added bytez model; proxy config listing the model without api_key and without the env var on the host; key stored under a differently-named env var.","solutions":["Pass api_key on the call: litellm.completion(..., api_key=\"...\").","Set the key in the environment so litellm resolves it (standard provider env pattern, e.g. BYTEZ_API_KEY) for the process running litellm.","For LiteLLM proxy, add api_key to the model's config entry (litellm_params).","Verify the key reaches your code path by printing bool(api_key) just before the call."],"exampleFix":"# before\nlitellm.completion(model=\"bytez/meta-llama/Llama-3.1-8B-Instruct\", messages=msgs)\n\n# after\nlitellm.completion(\n    model=\"bytez/meta-llama/Llama-3.1-8B-Instruct\",\n    messages=msgs,\n    api_key=os.environ[\"BYTEZ_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef bytez_key() -> str | None:\n    return os.environ.get(\"BYTEZ_API_KEY\") or os.environ.get(\"BYTEZ_API_TOKEN\")","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"bytez/org/model\", messages=msgs, api_key=key)\nexcept Exception as e:\n    if \"api_key\" in str(e):\n        raise RuntimeError(\"BYTEZ credentials missing\") from e\n    raise","preventionTips":["Resolve the key once at startup and fail fast if absent.","In proxy deployments, put api_key in the model's litellm_params so it is always attached."],"tags":["bytez","api-key","authentication","env-var"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}