{"record":{"id":"9e3c9dd8d738d192","repo":"BerriAI/litellm","slug":"togetherai-api-key-is-required-please-set-togeth","errorCode":null,"errorMessage":"TogetherAI API key is required, please set 'TOGETHERAI_API_KEY' in your environment","messagePattern":"TogetherAI API key is required, please set 'TOGETHERAI_API_KEY' in your environment","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/rerank_api/main.py","lineNumber":278,"sourceCode":"                api_base=api_base,\n                _is_async=_is_async,\n                headers=headers or litellm.headers or {},\n                client=client,\n                model_response=model_response,\n                litellm_params=rerank_litellm_params,\n            )\n        elif _custom_llm_provider == litellm.LlmProviders.TOGETHER_AI:\n            # Implement Together AI rerank logic\n            api_key = (\n                dynamic_api_key\n                or optional_params.api_key\n                or litellm.togetherai_api_key\n                or get_secret(\"TOGETHERAI_API_KEY\")\n                or litellm.api_key\n            )\n\n            if api_key is None:\n                raise ValueError(\"TogetherAI API key is required, please set 'TOGETHERAI_API_KEY' in your environment\")\n\n            response = together_rerank.rerank(\n                model=model,\n                query=query,\n                documents=documents,\n                top_n=top_n,\n                rank_fields=rank_fields,\n                return_documents=return_documents,\n                max_chunks_per_doc=max_chunks_per_doc,\n                api_key=api_key,\n                _is_async=_is_async,\n            )\n        elif _custom_llm_provider == litellm.LlmProviders.JINA_AI:\n            if dynamic_api_key is None:\n                raise ValueError(\"Jina AI API key is required, please set 'JINA_AI_API_KEY' in your environment\")\n\n            api_base = (\n                dynamic_api_base or optional_params.api_base or litellm.api_base or get_secret(\"BEDROCK_API_BASE\")","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/rerank_api/main.py#L260-L296","documentation":"Credential resolution guard for Together AI rerank: no API key came from the call, optional params, litellm globals, or the TOGETHERAI_API_KEY environment variable, so the rerank request cannot be authenticated.","triggerScenarios":"Thrown at litellm/rerank_api/main.py:278 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set TOGETHERAI_API_KEY in your environment."],"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-14T05:17:10.506Z"}