BerriAI/litellm · error · ValueError

Error compiling prompt '{prompt_id}': {e}

Error message

Error compiling prompt '{prompt_id}': {e}

What it means

A catch-all ValueError thrown at the end of the sync Phoenix compile helper when any exception escapes the try block while loading or rendering a prompt. The original exception is stringified into the message, so the real cause (network error, auth failure, template render error, KeyError in metadata) is nested in '{e}'. It masks the original exception type, so you must read the embedded text to diagnose.

Source

Thrown at litellm/integrations/arize/arize_phoenix_prompt_manager.py:419

                "temperature",
                "max_tokens",
                "top_p",
                "frequency_penalty",
                "presence_penalty",
            ]:
                if param in prompt_metadata:
                    optional_params[param] = prompt_metadata[param]

            return PromptManagementClient(
                prompt_id=prompt_id,
                prompt_template=rendered_messages,
                prompt_template_model=template_model,
                prompt_template_optional_params=optional_params,
                completed_messages=None,
            )

        except Exception as e:
            raise ValueError(f"Error compiling prompt '{prompt_id}': {e}")

    async def async_compile_prompt_helper(
        self,
        prompt_id: str | None,
        prompt_variables: dict | None,
        dynamic_callback_params: StandardCallbackDynamicParams,
        prompt_spec: PromptSpec | None = None,
        prompt_label: str | None = None,
        prompt_version: int | None = None,
    ) -> PromptManagementClient:
        """
        Async version of compile prompt helper. Since Arize Phoenix operations are synchronous,
        this simply delegates to the sync version.
        """
        if prompt_id is None:
            raise ValueError("prompt_id is required for Arize Phoenix prompt manager")
        return self._compile_prompt_helper(
            prompt_id=prompt_id,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read the '{e}' suffix of the message — it contains the underlying exception text; fix that root cause first
  2. Reproduce the load outside litellm: call the Phoenix client (get_prompt / render) directly with the same prompt_id and variables
  3. Check Phoenix connectivity and credentials (endpoint URL, API key) from the environment where litellm runs
  4. If the embedded error is a render error, test the template with the same prompt_variables in the Phoenix UI

Example fix

# before
try:
    client = manager._compile_prompt_helper(None, None, params)  # nested ValueError hides cause
except ValueError as e:
    pass  # real cause buried in message text

# after
# go through the public entry point and log the full chain
import logging
try:
    result = litellm.completion(model="phoenix/summarize-v2", messages=[...])
except ValueError as e:
    logging.exception("phoenix compile failed: %s", e)  # full text incl. embedded cause
Defensive patterns

Strategy: retry

Validate before calling

def can_reach_phoenix(endpoint: str, headers: dict) -> bool:
    import httpx
    try:
        r = httpx.get(f"{endpoint}/v1/prompts", headers=headers, timeout=5)
        return r.status_code < 500
    except httpx.HTTPError:
        return False

Try / catch

import time
for attempt in range(3):
    try:
        result = litellm.completion(model=f"phoenix/{prompt_id}", messages=[...])
        break
    except ValueError as e:
        msg = str(e)
        if any(k in msg for k in ("timeout", "connection", "503", "429")) and attempt < 2:
            time.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: Phoenix API unreachable or returning errors during _load_prompt_from_arize; invalid API key for Phoenix; template variables that fail during render_template (e.g. malformed template or incompatible variables); any unexpected exception while building the PromptManagementClient.

Common situations: Phoenix endpoint down or DNS failure; expired/incorrect Phoenix credentials; prompt template uses syntax the renderer rejects; transient 5xx from Phoenix during load; a prompt whose metadata is missing expected keys in a newer/older litellm version.

Related errors


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