Skip to content

Commit 505b594

Browse files
authored
Deprecate GeminiModel in favor of GoogleModel (#2416)
1 parent d914918 commit 505b594

File tree

19 files changed

+64
-322
lines changed

19 files changed

+64
-322
lines changed

docs/agents.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,20 +504,21 @@ The final request uses `temperature=0.0` (run-time), `max_tokens=500` (from mode
504504

505505
### Model specific settings
506506

507-
If you wish to further customize model behavior, you can use a subclass of [`ModelSettings`][pydantic_ai.settings.ModelSettings], like [`GeminiModelSettings`][pydantic_ai.models.gemini.GeminiModelSettings], associated with your model of choice.
507+
If you wish to further customize model behavior, you can use a subclass of [`ModelSettings`][pydantic_ai.settings.ModelSettings], like
508+
[`GoogleModelSettings`][pydantic_ai.models.google.GoogleModelSettings], associated with your model of choice.
508509

509510
For example:
510511

511512
```py
512513
from pydantic_ai import Agent, UnexpectedModelBehavior
513-
from pydantic_ai.models.gemini import GeminiModelSettings
514+
from pydantic_ai.models.google import GoogleModelSettings
514515

515516
agent = Agent('google-gla:gemini-1.5-flash')
516517

517518
try:
518519
result = agent.run_sync(
519520
'Write a list of 5 very rude things that I might say to the universe after stubbing my toe in the dark:',
520-
model_settings=GeminiModelSettings(
521+
model_settings=GoogleModelSettings(
521522
temperature=0.0, # general model settings can also be specified
522523
gemini_safety_settings=[
523524
{

docs/api/models/gemini.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/api/models/google.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# `pydantic_ai.models.google`
22

3+
Interface that uses the [`google-genai`](https://pypi.org/project/google-genai/) package under the hood to
4+
access Google's Gemini models via both the Generative Language API and Vertex AI.
5+
36
## Setup
47

58
For details on how to set up authentication with this model, see [model configuration for Google](../../models/google.md).

docs/api/providers.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
::: pydantic_ai.providers.google
66

7-
::: pydantic_ai.providers.google_vertex
8-
97
::: pydantic_ai.providers.openai
108

119
::: pydantic_ai.providers.deepseek

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
5757
"""
5858
```
5959

60-
1. We configure the agent to use [Gemini 1.5's Flash](api/models/gemini.md) model, but you can also set the model when running the agent.
60+
1. We configure the agent to use [Gemini 1.5's Flash](api/models/google.md) model, but you can also set the model when running the agent.
6161
2. Register a static [system prompt](agents.md#system-prompts) using a keyword argument to the agent.
6262
3. [Run the agent](agents.md#running-agents) synchronously, conducting a conversation with the LLM.
6363

docs/input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The situation is different for certain models:
110110

111111
- [`AnthropicModel`][pydantic_ai.models.anthropic.AnthropicModel]: if you provide a PDF document via `DocumentUrl`, the URL is sent directly in the API request, so no download happens on the user side.
112112

113-
- [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel] and [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on Vertex AI: any URL provided using `ImageUrl`, `AudioUrl`, `VideoUrl`, or `DocumentUrl` is sent as-is in the API request and no data is downloaded beforehand.
113+
- [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on Vertex AI: any URL provided using `ImageUrl`, `AudioUrl`, `VideoUrl`, or `DocumentUrl` is sent as-is in the API request and no data is downloaded beforehand.
114114

115115
See the [Gemini API docs for Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#filedata) to learn more about supported URLs, formats and limitations:
116116

@@ -120,4 +120,4 @@ The situation is different for certain models:
120120

121121
However, because of crawling restrictions, it may happen that Gemini can't access certain URLs. In that case, you can instruct Pydantic AI to download the file content and send that instead of the URL by setting the boolean flag `force_download` to `True`. This attribute is available on all objects that inherit from [`FileUrl`][pydantic_ai.messages.FileUrl].
122122

123-
- [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel] and [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on GLA: YouTube video URLs are sent directly in the request to the model.
123+
- [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on GLA: YouTube video URLs are sent directly in the request to the model.

docs/models/gemini.md

Lines changed: 0 additions & 263 deletions
This file was deleted.

docs/models/google.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ agent = Agent(model)
4444

4545
If you are an enterprise user, you can use the `google-vertex` provider with `GoogleModel` to access Gemini via Vertex AI.
4646

47+
This interface has a number of advantages over the Generative Language API:
48+
49+
1. The VertexAI API comes with more enterprise readiness guarantees.
50+
2. You can [purchase provisioned throughput](https://cloud.google.com/vertex-ai/generative-ai/docs/provisioned-throughput#purchase-provisioned-throughput) with VertexAI to guarantee capacity.
51+
3. If you're running Pydantic AI inside GCP, you don't need to set up authentication, it should "just work".
52+
4. You can decide which region to use, which might be important from a regulatory perspective, and might improve latency.
53+
54+
The big disadvantage is that for local development you may need to create and configure a "service account", which can be challenging to get right.
55+
56+
Whichever way you authenticate, you'll need to have VertexAI enabled in your GCP account.
57+
4758
To use Vertex AI, you may need to set up [application default credentials](https://cloud.google.com/docs/authentication/application-default-credentials) or use a service account. You can also specify the region.
4859

4960
#### Application Default Credentials

docs/models/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Pydantic AI is model-agnostic and has built-in support for multiple model provid
44

55
* [OpenAI](openai.md)
66
* [Anthropic](anthropic.md)
7-
* [Gemini](gemini.md) (via two different APIs: Generative Language API and VertexAI API)
7+
* [Gemini](google.md) (via two different APIs: Generative Language API and VertexAI API)
88
* [Groq](groq.md)
99
* [Mistral](mistral.md)
1010
* [Cohere](cohere.md)
@@ -41,13 +41,13 @@ Pydantic AI uses a few key terms to describe how it interacts with different LLM
4141
(generally by wrapping a vendor-provided SDK, like the `openai` python SDK). These classes implement a
4242
vendor-SDK-agnostic API, ensuring a single Pydantic AI agent is portable to different LLM vendors without
4343
any other code changes just by swapping out the Model it uses. Model classes are named
44-
roughly in the format `<VendorSdk>Model`, for example, we have `OpenAIModel`, `AnthropicModel`, `GeminiModel`,
44+
roughly in the format `<VendorSdk>Model`, for example, we have `OpenAIModel`, `AnthropicModel`, `GoogleModel`,
4545
etc. When using a Model class, you specify the actual LLM model name (e.g., `gpt-4o`,
4646
`claude-3-5-sonnet-latest`, `gemini-1.5-flash`) as a parameter.
4747
- **Provider**: This refers to provider-specific classes which handle the authentication and connections
4848
to an LLM vendor. Passing a non-default _Provider_ as a parameter to a Model is how you can ensure
4949
that your agent will make requests to a specific endpoint, or make use of a specific approach to
50-
authentication (e.g., you can use Vertex-specific auth with the `GeminiModel` by way of the `VertexProvider`).
50+
authentication (e.g., you can use Azure auth with the `OpenAIModel` by way of the `AzureProvider`).
5151
In particular, this is how you can make use of an AI gateway, or an LLM vendor that offers API compatibility
5252
with the vendor SDK used by an existing Model (such as `OpenAIModel`).
5353
- **Profile**: This refers to a description of how requests to a specific model or family of models need to be

0 commit comments

Comments
 (0)