BerriAI/litellm · error · Exception

{raw_response.text}

Error message

{raw_response.text}

What it means

Raised by the Jina AI rerank transformation when the HTTP status is not 200; the raw response body is re-raised as a plain Exception. Jina's API returns structured error bodies (invalid key, quota exceeded, bad request) whose text is surfaced verbatim.

Source

Thrown at litellm/llms/jina_ai/rerank/transformation.py:98

        optional_rerank_params: dict,
        headers: dict,
        litellm_params: dict | None = None,
    ) -> dict:
        return {"model": model, **optional_rerank_params}

    def transform_rerank_response(
        self,
        model: str,
        raw_response: Response,
        model_response: RerankResponse,
        logging_obj: LiteLLMLoggingObj,
        api_key: str | None = None,
        request_data: dict = {},
        optional_params: dict = {},
        litellm_params: dict = {},
    ) -> RerankResponse:
        if raw_response.status_code != 200:
            raise Exception(raw_response.text)

        logging_obj.post_call(original_response=raw_response.text)

        _json_response: Final = raw_response.json()

        _billed_units: Final = RerankBilledUnits(**_json_response.get("usage", {}))
        _tokens: Final = RerankTokens(**_json_response.get("usage", {}))
        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)

        _results: Final[list[dict] | None] = _json_response.get("results")

        if _results is None:
            raise ValueError(f"No results found in the response={_json_response}")

        # Transform Jina AI's response format to match LiteLLM's expected format
        # Jina AI returns: {"index": 0, "relevance_score": 0.72, "document": "hello"}
        # LiteLLM expects: {"index": 0, "relevance_score": 0.72, "document": {"text": "hello"}}
        transformed_results: Final = []

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read the exception message — it is Jina's own error payload naming the cause.
  2. Set a fresh key: api_key=... or the JINA_API_KEY environment variable.
  3. Check plan/quotas at jina.ai if the message mentions billing or rate limits.
  4. Confirm the model name exists under your account's accessible models.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    ranked = litellm.rerank(model='jina_ai/jina-reranker-v2-base-multilingual', query=q, documents=docs)
except Exception as e:
    msg = str(e).lower()
    if 'unauthorized' in msg or 'api key' in msg:
        raise AuthError('Jina key invalid') from e
    if 'rate' in msg or 'quota' in msg or 'billing' in msg:
        raise QuotaError('Jina quota exhausted') from e
    raise

Prevention

When it happens

Trigger: litellm.rerank(model='jina_ai/jina-reranker-v2-base-multilingual', ...) with an invalid/expired key (401), exhausted free credits (429/402), malformed request (400), or a non-existent model id (404).

Common situations: Hardcoded or rotated Jina API keys expiring; free-tier credit exhaustion in CI; passing Cohere-style params Jina rejects.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/045c3520ca6340d2. Report an issue: GitHub.