{"record":{"id":"34bf3c89624479f3","repo":"BerriAI/litellm","slug":"error-response-status-code-response-text","errorCode":null,"errorMessage":"Error: {response.status_code} - {response.text}","messagePattern":"Error: (.+?) - (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"cookbook/misc/migrate_proxy_config.py","lineNumber":81,"sourceCode":"        confirm = input(\n            \"\\033[92mDo you want to send the POST request with the above parameters? (y/n): \\033[0m\"\n        )\n        if confirm.lower() != \"y\":\n            print(\"Aborting POST request.\")\n            exit()\n\n        # Step 3: Call <proxy-base-url>/model/new for each model\n        url = f\"{proxy_base_url}/model/new\"\n        headers = {\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": f\"Bearer {master_key}\",\n        }\n        data = {\"model_name\": model_name, \"litellm_params\": litellm_params}\n        print(\"POSTING data to proxy url\", url)\n        response = requests.post(url, headers=headers, json=data)\n        if response.status_code != 200:\n            print(f\"Error: {response.status_code} - {response.text}\")\n            raise Exception(f\"Error: {response.status_code} - {response.text}\")\n\n        # Print the response for each model\n        print(\n            f\"Response for model '{model_name}': Status Code:{response.status_code} - {response.text}\"\n        )\n\n\n# Usage\nconfig_file = \"config.yaml\"\nproxy_base_url = \"http://0.0.0.0:4000\"\nmaster_key = \"sk-1234\"\nprint(f\"config_file: {config_file}\")\nprint(f\"proxy_base_url: {proxy_base_url}\")\nmigrate_models(config_file, proxy_base_url)\n","sourceCodeStart":63,"sourceCodeEnd":96,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/cookbook/misc/migrate_proxy_config.py#L63-L96","documentation":"LiteLLM's OpenAI Evals transformation requires an API key to build the Authorization header for evals endpoints. The lookup order is: litellm_params.api_key -> litellm.api_key -> litellm.openai_key -> the OPENAI_API_KEY environment variable (via the secret manager). If every source is empty, this ValueError is raised before any HTTP request is made - it is a local configuration error, not an upstream API error.","triggerScenarios":"Calling litellm eval APIs (create/retrieve eval runs against OpenAI) without passing api_key in the request, without setting litellm.api_key / litellm.openai_key in code, and without OPENAI_API_KEY in the environment (or in a configured secret manager).","commonSituations":"New eval workflows where the developer relied only on a router-level key not visible to the evals path; CI environments lacking env vars; .env files not loaded before the call; key stored under a different name (e.g. OPENAI_API_KEY_BYPASS) without aliasing.","solutions":["Export OPENAI_API_KEY in the shell or CI environment: export OPENAI_API_KEY=sk-...","Or set it in code before the eval call: litellm.api_key = 'sk-...'.","Or pass api_key explicitly in the litellm_params of the eval request.","If using a secret manager, confirm the secret name is exactly OPENAI_API_KEY and reachable."],"exampleFix":"# before\nresult = litellm.acreate_eval(...)  # no key anywhere\n\n# after\nimport os\nos.environ[\"OPENAI_API_KEY\"] = \"sk-...\"  # or pass api_key in litellm_params\nresult = litellm.acreate_eval(..., api_key=\"sk-...\")","handlingStrategy":"validation","validationCode":"import os, litellm\n\ndef evals_api_key_present() -> bool:\n    return bool(\n        litellm.api_key or litellm.openai_key or os.environ.get(\"OPENAI_API_KEY\")\n    )\n\nassert evals_api_key_present(), \"set OPENAI_API_KEY before running evals\"","typeGuard":null,"tryCatchPattern":"try:\n    result = litellm.acreate_eval(...)\nexcept ValueError as e:\n    if \"OPENAI_API_KEY is required\" in str(e):\n        os.environ[\"OPENAI_API_KEY\"] = load_key_from_vault()\n        result = litellm.acreate_eval(...)\n    else:\n        raise","preventionTips":["Add a startup assertion that an OpenAI key is resolvable before any eval run.","Keep one canonical key-loading helper for the whole app instead of ad-hoc env reads.","In CI, fail the job early on missing OPENAI_API_KEY rather than mid-eval."],"tags":["openai","evals","authentication","configuration","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}