Skip to content

Set 'us-central1' by default on GoogleProvider #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pydantic_ai_slim/pydantic_ai/providers/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self._client = genai.Client(
vertexai=vertexai,
project=project or os.environ.get('GOOGLE_CLOUD_PROJECT'),
location=location or os.environ.get('GOOGLE_CLOUD_LOCATION'),
location=location or os.environ.get('GOOGLE_CLOUD_LOCATION') or 'us-central1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
location=location or os.environ.get('GOOGLE_CLOUD_LOCATION') or 'us-central1',
location=location or os.environ.get('GOOGLE_CLOUD_LOCATION') or 'global',

I think that's better.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a perfect value according to the docs. Select quotes:

  • "Selecting a global endpoint for your requests can improve overall availability while reducing resource exhausted (429) errors"
  • Usage of the global endpoint is supported for the following Google models... [gemini 2.0 and 2.5]
  • For some models, Google also offers a global endpoint (Preview)

Currently us-central1 supports the most models by far of any region including global, but not all of them. us-central1 has all google models but is missing some Anthropic partner models, which use us-east5 instead. global has fewer models but higher availability.

Google is not making like easy!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not all models support global, I guess we have to stick to us-central1 - @Kludex let's add a comment with @dhimmel's details.

credentials=credentials,
http_options={'headers': {'User-Agent': get_user_agent()}},
)
Expand Down
Loading