{"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":"validation","errorClass":"Exception","httpStatus":null,"severity":"critical","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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bytez/chat/transformation.py#L120-L156","documentation":"In the same validate_environment call, Bytez requires an api_key (used as 'Authorization: Key <api_key>'). If api_key is falsy, this Exception is raised client-side before the request is sent. Bytez keys are resolved through litellm's standard api_key flow, so this means neither the argument nor BYTEZ_API_KEY was available.","triggerScenarios":"Calling litellm.completion(model=\"bytez/...\", ...) with no api_key argument while BYTEZ_API_KEY is unset in the environment.","commonSituations":"Missing env var in new environments/CI; key stored under a different name; proxy deployments where the key isn't configured for the bytez provider.","solutions":["export BYTEZ_API_KEY=<key> (from your Bytez account) in the runtime environment.","Or pass api_key directly to the completion call.","On litellm proxy, add api_key to the bytez provider's litellm_params entry."],"exampleFix":"# before\nlitellm.completion(model=\"bytez/meta-llama/Llama-3-8b\", messages=m)\n\n# after\nlitellm.completion(model=\"bytez/meta-llama/Llama-3-8b\", messages=m, api_key=os.environ[\"BYTEZ_API_KEY\"])","handlingStrategy":"validation","validationCode":"import os\n\nif not (os.getenv(\"BYTEZ_API_KEY\") or provided_api_key):\n    raise RuntimeError(\"BYTEZ_API_KEY missing; configure it before serving traffic\")","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"bytez/...\", messages=m)\nexcept Exception as e:\n    if \"Missing api_key\" in str(e):\n        raise SystemExit(\"Config error: set BYTEZ_API_KEY\") from e  # config failure, never retry\n    raise","preventionTips":["Assert required provider keys at process startup.","Document every env var your deployment needs in one checklist.","Alert on auth-config errors separately from runtime API errors."],"tags":["bytez","auth","api-key","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}