langchain-ai/deepagents · error · ModelConfigError
Google Cloud location is required for provider 'google_anthr
Error message
Google Cloud location is required for provider 'google_anthropic_vertex'. Set GOOGLE_CLOUD_LOCATION or DEEPAGENTS_CODE_GOOGLE_CLOUD_LOCATION, or pass 'location' in model params.
What it means
Raised when configuring the `google_anthropic_vertex` provider (Claude on Vertex AI) without a Google Cloud location. Vertex requires a project and a region; the library injects them from stored credentials or config params via `_apply_google_anthropic_vertex_kwargs` and refuses to guess the region. GCP endpoints are region-specific, so there is no safe default.
Source
Thrown at libs/code/deepagents_code/config.py:5309
Raises:
ModelConfigError: If no location is configured.
"""
if provider != "google_anthropic_vertex":
return
credentials = _get_credentials()
if credentials.google_cloud_project:
kwargs.setdefault("project", credentials.google_cloud_project)
if credentials.google_cloud_location:
kwargs.setdefault("location", credentials.google_cloud_location)
if not kwargs.get("location"):
from deepagents_code.model_config import ModelConfigError
msg = (
"Google Cloud location is required for provider "
"'google_anthropic_vertex'. Set GOOGLE_CLOUD_LOCATION or "
"DEEPAGENTS_CODE_GOOGLE_CLOUD_LOCATION, or pass 'location' in model params."
)
raise ModelConfigError(msg)
def _compose_openai_reasoning_effort(
provider: str,
kwargs: dict[str, Any],
effort_override: object,
reasoning_override: object,
) -> dict[str, Any]:
"""Compose a session effort override with an OpenAI reasoning mapping.
Args:
provider: Resolved model provider.
kwargs: Layered model constructor parameters.
effort_override: High-priority `reasoning_effort` from session params.
reasoning_override: High-priority native `reasoning` from session params.
Returns:
Constructor parameters with one native `reasoning` mapping whenView on GitHub (pinned to a1af029e6e)
Solutions
- Set `export GOOGLE_CLOUD_LOCATION=us-east5` (or your region)
- Set DEEPAGENTS_CODE_GOOGLE_CLOUD_LOCATION as the app-specific override
- Pass `location` in model params: `[providers."google_anthropic_vertex".params] location = "us-east5"` in config.toml or as a model kwarg
Example fix
// before $ dcode -m google_anthropic_vertex:claude-sonnet-4 ModelConfigError: Google Cloud location is required... // after $ export GOOGLE_CLOUD_PROJECT=my-project $ export GOOGLE_CLOUD_LOCATION=us-east5 $ dcode -m google_anthropic_vertex:claude-sonnet-4
Defensive patterns
Strategy: validation
Validate before calling
import os
def vertex_location_ok() -> bool:
return bool(
os.environ.get("GOOGLE_CLOUD_LOCATION")
or os.environ.get("DEEPAGENTS_CODE_GOOGLE_CLOUD_LOCATION")
) Try / catch
from deepagents_code.model_config import ModelConfigError
try:
model = create_model("google_anthropic_vertex:claude-sonnet-4")
except ModelConfigError as e:
if "location is required" in str(e):
os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "us-east5")
model = create_model("google_anthropic_vertex:claude-sonnet-4")
else:
raise Prevention
- Always set GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION together for Vertex
- Put `location` in the provider's `params` table in config.toml for team-wide configs
- Match the region to one where the Claude models are available
When it happens
Trigger: Creating a model with provider `google_anthropic_vertex` when, after merging stored credentials and config.toml `params`, `kwargs` still has no `location`: GOOGLE_CLOUD_LOCATION and DEEPAGENTS_CODE_GOOGLE_CLOUD_LOCATION are unset and no `location` appears in model params (config.py:5294-5309).
Common situations: Authenticating via Application Default Credentials where the project is detected but the region is not; CI environments with only GOOGLE_CLOUD_PROJECT set; copying a working config from another region without mirroring the location.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- No credentials configured. Please set one of: ANTHROPIC_API_
- Claude model '{model_name}' uses the Anthropic Messages API
- No credentials found for provider '{provider}'. Please set t
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/f21ddec2eb10fc2c.
Report an issue: GitHub.