BerriAI/litellm · error · PalmError

traceback.format_exc()

Error message

traceback.format_exc()

What it means

Response-mapping failure in the PaLM completion path: while converting response.candidates into LiteLLM Choices, an unexpected exception occurred, and the formatted traceback is attached to the PalmError (with the original status code) for diagnosis.

Solutions

  1. Read the wrapped exception text; this is a generic re-raise from the deprecated palm provider.
  2. Migrate to the gemini provider, since palm is deprecated.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/llms/deprecated_providers/palm.py:167 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/44288a20859073eb. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/deprecated_providers/palm.py:167

        api_key="",
        original_response=response,
        additional_args={"complete_input_dict": {}},
    )
    print_verbose(f"raw model_response: {response}")
    ## RESPONSE OBJECT
    completion_response = response
    try:
        choices_list: Final = []
        for idx, item in enumerate(completion_response.candidates):
            if len(item["output"]) > 0:
                message_obj = Message(content=item["output"])
            else:
                message_obj = Message(content=None)
            choice_obj = Choices(index=idx + 1, message=message_obj)
            choices_list.append(choice_obj)
        model_response.choices = choices_list
    except Exception:
        raise PalmError(message=traceback.format_exc(), status_code=response.status_code)

    try:
        completion_response = model_response["choices"][0]["message"].get("content")
    except Exception:
        raise PalmError(
            status_code=400,
            message=f"No response received. Original response - {response}",
        )

    ## CALCULATING USAGE - baseten charges on time, not tokens - have some mapping of cost here.
    prompt_tokens: Final = len(encoding.encode(prompt))
    completion_tokens: Final = len(encoding.encode(model_response["choices"][0]["message"].get("content", "")))

    model_response.created = int(time.time())
    model_response.model = "palm/" + model
    usage: Final = Usage(
        prompt_tokens=prompt_tokens,
        completion_tokens=completion_tokens,

View on GitHub (pinned to 77b7c6c40c)