BerriAI/litellm · error · ValueError
Error calling litellm.acompletion for generate_content
Error message
Error calling litellm.acompletion for generate_content: {e} What it means
Wrapper around litellm.acompletion for the generate_content endpoint: the inner call raised (error text interpolated), and the adapter re-raises so callers see the underlying completion failure in the GenAI-compat context.
Solutions
- Inspect the wrapped exception {e} for the root cause (auth, model name, provider outage).
- Verify the model and credentials used by the underlying litellm.acompletion call.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/google_genai/adapters/handler.py:102 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/c5bb63e82a49b947.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/google_genai/adapters/handler.py:102
)
return generate_content_response
else:
# Transform streaming completion response to generate_content format
transformed_stream: Final = GOOGLE_GENAI_ADAPTER.translate_completion_output_params_streaming(
completion_response
)
if transformed_stream is not None:
return transformed_stream
raise ValueError("Failed to transform streaming response")
else:
# Transform completion response back to generate_content format
generate_content_response = GOOGLE_GENAI_ADAPTER.translate_completion_to_generate_content(
cast(ModelResponse, completion_response)
)
return generate_content_response
except Exception as e:
raise ValueError(f"Error calling litellm.acompletion for generate_content: {e}")
@staticmethod
def generate_content_handler(
model: str,
contents: list[dict[str, object]] | dict[str, object],
litellm_params: GenericLiteLLMParams,
config: dict[str, object] | None = None,
stream: bool = False,
_is_async: bool = False,
**kwargs: object,
) -> dict[str, object] | AsyncIterator[bytes] | Coroutine[None, None, dict[str, object] | AsyncIterator[bytes]]:
"""Handle generate_content call using completion adapter"""
if _is_async:
return GenerateContentToCompletionHandler.async_generate_content_handler(
model=model,
contents=contents,
config=config,View on GitHub (pinned to 77b7c6c40c)