{"record":{"id":"9b0f46d545897ea2","repo":"BerriAI/litellm","slug":"required-openai-api-key-in-environment-to-make-p","errorCode":null,"errorMessage":"Required 'OPENAI_API_KEY' in environment to make pass-through calls to OpenAI.","messagePattern":"Required 'OPENAI_API_KEY' in environment to make pass-through calls to OpenAI\\.","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py","lineNumber":1962,"sourceCode":"        - /openai/v1/chat/completions\n        - /openai/v1/assistants\n        - /openai/v1/threads\n\n        Dedicated passthrough (for Responses API):\n        - /openai_passthrough/v1/responses\n        - /openai_passthrough/v1/responses/{response_id}\n        - /openai_passthrough/v1/responses/{response_id}/input_items\n\n    [Docs](https://docs.litellm.ai/docs/pass_through/openai_passthrough)\n    \"\"\"\n    base_target_url: Final = os.getenv(\"OPENAI_API_BASE\") or \"https://api.openai.com/\"\n    # Add or update query parameters\n    openai_api_key: Final = passthrough_endpoint_router.get_credentials(\n        custom_llm_provider=litellm.LlmProviders.OPENAI.value,\n        region_name=None,\n    )\n    if openai_api_key is None:\n        raise Exception(\"Required 'OPENAI_API_KEY' in environment to make pass-through calls to OpenAI.\")\n\n    return await BaseOpenAIPassThroughHandler._base_openai_pass_through_handler(\n        endpoint=endpoint,\n        request=request,\n        fastapi_response=fastapi_response,\n        user_api_key_dict=user_api_key_dict,\n        base_target_url=base_target_url,\n        api_key=openai_api_key,\n        custom_llm_provider=litellm.LlmProviders.OPENAI,\n    )\n\n\ndef _join_url_paths(base_url: httpx.URL, path: str, custom_llm_provider: litellm.LlmProviders) -> str:\n    \"\"\"\n    Properly joins a base URL with a path, preserving any existing path in the base URL.\n    \"\"\"\n    # Combine paths via the shared helper so any '..' in the path cannot\n    # climb above the configured base path.","sourceCodeStart":1944,"sourceCodeEnd":1980,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py#L1944-L1980","documentation":"Guard in the OpenAI pass-through: after checking the credential router, no OpenAI API key is available, so the proxy falls back to the OPENAI_API_KEY environment variable, which is unset — the request to api.openai.com cannot be authenticated.","triggerScenarios":"Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:1962 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set OPENAI_API_KEY in the proxy environment.","Alternatively configure the key on the model entry via the UI or config.yaml."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}