BerriAI/litellm · error · Exception

Failed to fetch prompt version

Error message

Failed to fetch prompt version '{prompt_version_id}': {e}

What it means

Catch-all for HTTP errors in ArizePhoenixClient.get_prompt_version that are not 401/403/404: the request reached Phoenix, authentication passed, but the server returned another error status (500, 502, 429, …). The original exception is embedded in the message so the status code and body are preserved.

Solutions

  1. Inspect the embedded exception/status in the message to identify the actual code before acting
  2. For 429/5xx transient errors, retry with backoff — the fetch is a read-only GET and is safe to repeat
  3. Check Phoenix status page / server logs for 5xx; for self-hosted, verify the service is healthy and the api_base proxy is up
  4. Cache loaded prompts so transient Phoenix outages do not break request serving
Defensive patterns

Strategy: retry

Validate before calling

import httpx, os

resp = httpx.get(
    f"{api_base}/prompt_versions/{prompt_version_id}",
    headers={"Authorization": f"Bearer {os.environ['PHOENIX_API_KEY']}"},
    timeout=5,
)
if resp.status_code >= 500 or resp.status_code == 429:
    log.warning("Phoenix transient status %s — will retry", resp.status_code)

Try / catch

from tenacity import retry, wait_exponential, retry_if_exception_message

@retry(
    retry=retry_if_exception_message(match=".*Failed to fetch prompt version.*"),
    wait=wait_exponential(multiplier=1, max=30),
    stop=stop_after_attempt(4),
)
def load_prompt(pid: str):
    return manager.compile(prompt_id=pid, prompt_variables=vars)

Prevention

When it happens

Trigger: Phoenix backend returns 5xx while fetching /prompt_versions/<id>; rate limiting (429) on Phoenix Cloud; malformed request producing 400; gateway timeouts (504) behind a proxy. Surfaces via the prompt manager as 'Failed to load prompt version …' when litellm tries to use the prompt.

Common situations: Phoenix Cloud incidents or throttling during bursts of prompt loads; self-hosted Phoenix restarting or out of memory; a proxy in front of Phoenix returning 502 because the upstream is down.

Related errors


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

Appendix: source

Thrown at litellm/integrations/arize/arize_phoenix_client.py:90

            response.raise_for_status()

            data: Final = response.json()
            return data.get("data")

        except Exception as e:
            # Check if it's an HTTP error
            response = getattr(e, "response", None)
            if response is not None and hasattr(response, "status_code"):
                if response.status_code == 404:
                    return None
                elif response.status_code == 403:
                    raise Exception(
                        f"Access denied to prompt version '{prompt_version_id}'. Check your Arize Phoenix permissions."
                    )
                elif response.status_code == 401:
                    raise Exception("Authentication failed. Check your Arize Phoenix API key and permissions.")
                else:
                    raise Exception(f"Failed to fetch prompt version '{prompt_version_id}': {e}")
            else:
                raise Exception(f"Error fetching prompt version '{prompt_version_id}': {e}")

    def test_connection(self) -> bool:
        """
        Test the connection to the Arize Phoenix API.

        Returns:
            True if connection is successful, False otherwise
        """
        try:
            # Try to access the prompt_versions endpoint to test connection
            url: Final = f"{self.api_base}/prompt_versions"
            response: Final = self.http_handler.client.get(url, headers=self.headers)
            response.raise_for_status()
            return True
        except Exception:
            return False

View on GitHub (pinned to 77b7c6c40c)