BerriAI/litellm · error · ValueError
Model parameter is required for Gemini custom API base URLs
Error message
Model parameter is required for Gemini custom API base URLs
What it means
Raised in URL construction for a Gemini (Google AI Studio) custom api_base: no model name was supplied, so the /models/{model}:{endpoint} path cannot be built. Gemini custom bases have no default model to fall back to.
Source
Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:639
1. Gemini (Google AI Studio) - constructs /models/{model}:{endpoint}
2. Vertex AI with standard proxies - constructs {api_base}:{endpoint};
if api_base has no path (bare host), grafts the default vertex URL path onto it
3. Vertex AI with PSC endpoints - constructs full path structure
{api_base}/v1/projects/{project}/locations/{location}/endpoints/{model}:{endpoint}
(only when use_psc_endpoint_format=True)
Args:
use_psc_endpoint_format: If True, constructs PSC endpoint URL format.
If False (default), uses api_base as-is and appends :{endpoint}
## Returns
- (auth_header, url) - Tuple[Optional[str], str]
"""
if api_base:
if custom_llm_provider == "gemini":
# For Gemini (Google AI Studio), construct the full path like other providers
if model is None:
raise ValueError("Model parameter is required for Gemini custom API base URLs")
url = f"{api_base}/models/{model}:{endpoint}"
if gemini_api_key is None:
raise ValueError(
"Missing Gemini API key. Set the GEMINI_API_KEY or GOOGLE_API_KEY environment variable."
)
if gemini_api_key is not None:
auth_header = {"x-goog-api-key": gemini_api_key}
else:
# For Vertex AI
if use_psc_endpoint_format:
# User explicitly specified PSC endpoint format
# Construct full PSC/custom endpoint URL
if not (vertex_project and vertex_location and model):
raise ValueError(
"vertex_project, vertex_location, and model are required when use_psc_endpoint_format=True"
)
# Strip routing prefixes (bge/, gemma/, etc.) for endpoint URL construction
model_for_url: Final = get_vertex_base_model_name(model=model)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass the 'model' parameter when using a custom api_base for Gemini so the request path can be constructed.
- Include the model name in the call, e.g. model='vertex_ai/gemini-1.5-pro' together with api_base.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:639 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/b43c0e8a38f51601.
Report an issue: GitHub.