{"record":{"id":"3f7a64e5aee8e17b","repo":"BerriAI/litellm","slug":"deepinfra-api-key-is-required-please-set-deepinf","errorCode":null,"errorMessage":"Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable","messagePattern":"Deepinfra API key is required\\. Please set 'DEEPINFRA_API_KEY' environment variable","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/deepinfra/rerank/transformation.py","lineNumber":75,"sourceCode":"\n        # Remove any trailing slashes for consistency, then add one\n        api_base_clean = api_base_clean.rstrip(\"/\") + \"/\"\n\n        # Compose the full endpoint\n        return f\"{api_base_clean}inference/{model}\"\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        api_key: str | None = None,\n        optional_params: dict | None = None,\n    ) -> dict:\n        if api_key is None:\n            api_key = get_secret_str(\"DEEPINFRA_API_KEY\")\n\n        if api_key is None:\n            raise ValueError(\"Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable\")\n\n        default_headers: Final = {\n            \"Authorization\": f\"Bearer {api_key}\",\n            \"accept\": \"application/json\",\n            \"content-type\": \"application/json\",\n        }\n\n        # If 'Authorization' is provided in headers, it overrides the default.\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        # Merge other headers, overriding any default ones except Authorization\n        return {**default_headers, **headers}\n\n    def map_cohere_rerank_params(\n        self,\n        non_default_params: dict,\n        model: str,","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/deepinfra/rerank/transformation.py#L57-L93","documentation":"Error \"Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/deepinfra/rerank/transformation.py:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set DEEPINFRA_API_KEY in the environment."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}