BerriAI/litellm · error · ValueError

TogetherAI API key is required, please set 'TOGETHERAI_API_K

Error message

TogetherAI API key is required, please set 'TOGETHERAI_API_KEY' in your environment

What it means

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.

Source

Thrown at litellm/rerank_api/main.py:278

                api_base=api_base,
                _is_async=_is_async,
                headers=headers or litellm.headers or {},
                client=client,
                model_response=model_response,
                litellm_params=rerank_litellm_params,
            )
        elif _custom_llm_provider == litellm.LlmProviders.TOGETHER_AI:
            # Implement Together AI rerank logic
            api_key = (
                dynamic_api_key
                or optional_params.api_key
                or litellm.togetherai_api_key
                or get_secret("TOGETHERAI_API_KEY")
                or litellm.api_key
            )

            if api_key is None:
                raise ValueError("TogetherAI API key is required, please set 'TOGETHERAI_API_KEY' in your environment")

            response = together_rerank.rerank(
                model=model,
                query=query,
                documents=documents,
                top_n=top_n,
                rank_fields=rank_fields,
                return_documents=return_documents,
                max_chunks_per_doc=max_chunks_per_doc,
                api_key=api_key,
                _is_async=_is_async,
            )
        elif _custom_llm_provider == litellm.LlmProviders.JINA_AI:
            if dynamic_api_key is None:
                raise ValueError("Jina AI API key is required, please set 'JINA_AI_API_KEY' in your environment")

            api_base = (
                dynamic_api_base or optional_params.api_base or litellm.api_base or get_secret("BEDROCK_API_BASE")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set TOGETHERAI_API_KEY in your environment.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/rerank_api/main.py:278 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/9e3c9dd8d738d192. Report an issue: GitHub.