{"record":{"id":"856e2bf9bfccd31c","repo":"BerriAI/litellm","slug":"voyage-ai-api-key-is-required-set-via-api-key-p","errorCode":null,"errorMessage":"Voyage AI API key is required. Set via `api_key` parameter or `VOYAGE_API_KEY` env var.","messagePattern":"Voyage AI API key is required\\. Set via `api_key` parameter or `VOYAGE_API_KEY` env var\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/voyage/rerank/transformation.py","lineNumber":144,"sourceCode":"        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)\n\n        return RerankResponse(\n            id=_json_response.get(\"id\", f\"voyage-rerank-{model}\"),\n            results=transformed_results,\n            meta=rerank_meta,\n        )\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(\"VOYAGE_API_KEY\") or get_secret_str(\"VOYAGE_AI_API_KEY\")\n        if api_key is None:\n            raise ValueError(\"Voyage AI API key is required. Set via `api_key` parameter or `VOYAGE_API_KEY` env var.\")\n        return {\n            \"Authorization\": f\"Bearer {api_key}\",\n            \"content-type\": \"application/json\",\n        }\n\n    def calculate_rerank_cost(\n        self,\n        model: str,\n        custom_llm_provider: str | None = None,\n        billed_units: RerankBilledUnits | None = None,\n        model_info: ModelInfo | None = None,\n    ) -> tuple[float, float]:\n        if (\n            model_info is None\n            or \"input_cost_per_token\" not in model_info\n            or model_info[\"input_cost_per_token\"] is None\n            or billed_units is None\n        ):","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/voyage/rerank/transformation.py#L126-L162","documentation":"VoyageRerankConfig.validate_environment resolves the key from the api_key argument or the env chain VOYAGE_API_KEY / VOYAGE_AI_API_KEY. If none is found it raises this ValueError while building the Authorization header, so no network call is attempted. Note this rerank path does not check VOYAGE_AI_TOKEN (unlike the multimodal embedding path).","triggerScenarios":"litellm.rerank(model=\"voyage/voyage-3-rerank\", query=..., documents=[...]) with no api_key and no VOYAGE_API_KEY/VOYAGE_AI_API_KEY set; the key stored only under VOYAGE_AI_TOKEN, which this path does not read.","commonSituations":"Working embedding calls (which accept VOYAGE_AI_TOKEN) followed by a failing rerank call with the same env; fresh CI containers; keys configured in the proxy for chat models but not for the rerank route.","solutions":["Export VOYAGE_API_KEY (or VOYAGE_AI_API_KEY): export VOYAGE_API_KEY=pa-....","Or pass api_key explicitly to litellm.rerank.","If you only have VOYAGE_AI_TOKEN, also export it as VOYAGE_API_KEY for the rerank path.","In LiteLLM proxy config, set api_key inside the voyage rerank model's litellm_params."],"exampleFix":"# before\nresult = litellm.rerank(model=\"voyage/voyage-3-rerank\", query=q, documents=docs)\n# -> ValueError: Voyage AI API key is required...\n\n# after\nresult = litellm.rerank(\n    model=\"voyage/voyage-3-rerank\",\n    query=q,\n    documents=docs,\n    api_key=os.environ[\"VOYAGE_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\nVOYAGE_KEY = os.getenv(\"VOYAGE_API_KEY\") or os.getenv(\"VOYAGE_AI_API_KEY\")\nif not VOYAGE_KEY:\n    raise RuntimeError(\"Voyage rerank needs VOYAGE_API_KEY (VOYAGE_AI_TOKEN is NOT read on this path)\")\nresult = litellm.rerank(model=\"voyage/voyage-3-rerank\", query=q, documents=docs, api_key=VOYAGE_KEY)","typeGuard":"const hasVoyageRerankKey = (env: Record<string, string | undefined>): boolean =>\n  Boolean(env.VOYAGE_API_KEY ?? env.VOYAGE_AI_API_KEY);","tryCatchPattern":"try:\n    result = litellm.rerank(model=\"voyage/voyage-3-rerank\", query=q, documents=docs)\nexcept ValueError as e:\n    if \"Voyage AI API key is required\" in str(e):\n        raise RuntimeError(\"Set VOYAGE_API_KEY for rerank calls\") from e\n    raise","preventionTips":["Export VOYAGE_API_KEY - do not rely on VOYAGE_AI_TOKEN for rerank.","Centralize provider key resolution in one config module and unit-test it.","Healthcheck endpoints should verify required env vars per enabled provider."],"tags":["voyage","rerank","api-key","authentication","environment-variable","litellm"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}