{"record":{"id":"bb4a88282e556696","repo":"BerriAI/litellm","slug":"missing-novita-ai-api-key-a-call-is-being-made-t","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/novita/chat/transformation.py","lineNumber":25,"sourceCode":"\"\"\"\n\nfrom ....types.llms.openai import AllMessageValues\nfrom ...openai.chat.gpt_transformation import OpenAIGPTConfig\n\n\nclass NovitaConfig(OpenAIGPTConfig):\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        if api_key is None:\n            raise ValueError(\n                \"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\"\n            )\n        headers[\"Authorization\"] = f\"Bearer {api_key}\"\n        headers[\"Content-Type\"] = \"application/json\"\n        headers[\"X-Novita-Source\"] = \"litellm\"\n        return headers\n","sourceCodeStart":7,"sourceCodeEnd":32,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/novita/chat/transformation.py#L7-L32","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\nout = litellm.completion(model=\"novita/meta-llama/Llama-3-8B-Instruct\", messages=msgs)\n\n# after\nout = litellm.completion(\n    model=\"novita/meta-llama/Llama-3-8B-Instruct\",\n    messages=msgs,\n    api_key=os.environ[\"NOVITA_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"NOVITA_API_KEY\"):\n    raise RuntimeError(\"NOVITA_API_KEY not set (get one at novita.ai)\")","typeGuard":null,"tryCatchPattern":"try:\n    out = litellm.completion(model=\"novita/meta-llama/Llama-3-8B-Instruct\", messages=msgs)\nexcept ValueError as e:\n    if \"Missing Novita AI API Key\" in str(e):\n        raise RuntimeError(\"Config error: NOVITA_API_KEY missing\") from e\n    raise","preventionTips":["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."],"tags":["novita","api-key","configuration","chat"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}