BerriAI/litellm · critical · Exception
Missing api_key, make sure you pass in your api key
Error message
Missing api_key, make sure you pass in your api key
What it means
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.
Source
Thrown at litellm/llms/bytez/chat/transformation.py:138
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
api_key: str | None = None,
api_base: str | None = None,
) -> dict:
headers.update(
{
"content-type": "application/json",
"Authorization": f"Key {api_key}",
"user-agent": f"litellm/{version}",
}
)
if not messages:
raise Exception("kwarg `messages` must be an array of messages that follow the openai chat standard")
if not api_key:
raise Exception("Missing api_key, make sure you pass in your api key")
return headers
def get_complete_url(
self,
api_base: str | None,
api_key: str | None,
model: str,
optional_params: dict,
litellm_params: dict,
stream: bool | None = None,
) -> str:
encoded_model: Final = encode_url_path_segments(model, field_name="model")
return f"{API_BASE}/{encoded_model}"
def transform_request(
self,
model: str,View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before litellm.completion(model="bytez/meta-llama/Llama-3-8b", messages=m) # after litellm.completion(model="bytez/meta-llama/Llama-3-8b", messages=m, api_key=os.environ["BYTEZ_API_KEY"])
Defensive patterns
Strategy: validation
Validate before calling
import os
if not (os.getenv("BYTEZ_API_KEY") or provided_api_key):
raise RuntimeError("BYTEZ_API_KEY missing; configure it before serving traffic") Try / catch
try:
litellm.completion(model="bytez/...", messages=m)
except Exception as e:
if "Missing api_key" in str(e):
raise SystemExit("Config error: set BYTEZ_API_KEY") from e # config failure, never retry
raise Prevention
- 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.
When it happens
Trigger: Calling litellm.completion(model="bytez/...", ...) with no api_key argument while BYTEZ_API_KEY is unset in the environment.
Common situations: 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.
Related errors
- Missing Anthropic API Key
- Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTH
- ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Sk
- APISERPENT_API_KEY is not set. Set `APISERPENT_API_KEY` envi
- BFL_API_KEY is not set. Please set it via environment variab
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/68115b97477350dc.
Report an issue: GitHub.