Skip to content

google-vertex provider now uses google-genai but fails due to no default location  #2023

Closed
@dhimmel

Description

@dhimmel

Here's my code:

from pydantic_ai import Agent

def test_pydantic_ai_agent_sync() -> None:
    agent = Agent(
        model="google-vertex:gemini-2.0-flash",
    )
    result = agent.run_sync(
        user_prompt="This is a test. Respond with only the word 'okay'."
    )
    assert result.output.strip() == "okay"

And I'm getting the error:

ImportError: Please install `google-genai` to use the Google model, you can use the `google` optional group — `pip install "pydantic-ai-slim[google]"

My environment specifies pydantic-ai-slim[vertexai].

The expected behavior here is that the google-vertex provider would be used and the google-genai package would not be needed.

I am very confused because the above code used to work, and I'm not really sure what changed... perhaps an update or some additional configuration or environment setting got set on my system?

I am seeing this in the stacktrace:

.venv/lib/python3.13/site-packages/pydantic_ai/agent.py:289: in __init__
    self.model = models.infer_model(model)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/pydantic_ai/models/__init__.py:564: in infer_model
    from .google import GoogleModel

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions