BerriAI/litellm · error · ValueError
Missing Novita AI API Key - A call is being made to novita b
Error message
Missing Novita AI API Key - A call is being made to novita but no key is set either in the environment variables or via params
What it means
Raised by NovitaConfig.validate_environment when api_key is None: a call to a novita/* model was made without an api_key parameter. Unlike most providers, this check does not fall back to an environment variable lookup inside the transformer — litellm's caller layer normally resolves the NOVITA_API_KEY env var, so hitting this means the key was not supplied anywhere.
Source
Thrown at litellm/llms/novita/chat/transformation.py:25
"""
from ....types.llms.openai import AllMessageValues
from ...openai.chat.gpt_transformation import OpenAIGPTConfig
class NovitaConfig(OpenAIGPTConfig):
def validate_environment(
self,
headers: dict,
model: str,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
api_key: str | None = None,
api_base: str | None = None,
) -> dict:
if api_key is None:
raise ValueError(
"Missing Novita AI API Key - A call is being made to novita but no key is set either in the environment variables or via params"
)
headers["Authorization"] = f"Bearer {api_key}"
headers["Content-Type"] = "application/json"
headers["X-Novita-Source"] = "litellm"
return headers
View on GitHub (pinned to 6c2dcb801b)
Solutions
- export NOVITA_API_KEY=<key from novita.ai> and re-run.
- Or pass api_key explicitly to the completion call.
- In litellm proxy, set api_key under the novita model's litellm_params in config.yaml.
- Print bool(os.getenv('NOVITA_API_KEY')) to confirm the env var is actually visible to the process.
Example fix
# before
out = litellm.completion(model="novita/meta-llama/Llama-3-8B-Instruct", messages=msgs)
# after
out = litellm.completion(
model="novita/meta-llama/Llama-3-8B-Instruct",
messages=msgs,
api_key=os.environ["NOVITA_API_KEY"],
) Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("NOVITA_API_KEY"):
raise RuntimeError("NOVITA_API_KEY not set (get one at novita.ai)") Try / catch
try:
out = litellm.completion(model="novita/meta-llama/Llama-3-8B-Instruct", messages=msgs)
except ValueError as e:
if "Missing Novita AI API Key" in str(e):
raise RuntimeError("Config error: NOVITA_API_KEY missing") from e
raise Prevention
- Assert provider env vars at startup for every model you route to.
- In proxy configs, set api_key per novita deployment explicitly.
- Automate secret injection (k8s secrets, SSM) instead of manual exports.
When it happens
Trigger: Calling litellm.completion(model='novita/...') with no api_key argument and no NOVITA_API_KEY environment variable set (litellm would otherwise inject it as the api_key param).
Common situations: Env var missing in the deployed environment (container, serverless, CI), typo in NOVITA_API_KEY, or proxy config missing the key in the model's litellm_params.
Related errors
- Azure OpenAI client is not initialized. Make sure api_key is
- api_key is None. Please set AZURE_AI_API_KEY or dynamically
- Azure AI API key is required for model {model}. Set AZURE_AI
- BFL_API_KEY is not set. Please set it via environment variab
- Missing Cloudflare API Key - A call is being made to cloudfl
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/bb4a88282e556696.
Report an issue: GitHub.