Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,20 +504,21 @@ The final request uses `temperature=0.0` (run-time), `max_tokens=500` (from mode

### Model specific settings

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.
If you wish to further customize model behavior, you can use a subclass of [`ModelSettings`][pydantic_ai.settings.ModelSettings], like
[`GoogleModelSettings`][pydantic_ai.models.google.GoogleModelSettings], associated with your model of choice.

For example:

```py
from pydantic_ai import Agent, UnexpectedModelBehavior
from pydantic_ai.models.gemini import GeminiModelSettings
from pydantic_ai.models.google import GoogleModelSettings

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

try:
result = agent.run_sync(
'Write a list of 5 very rude things that I might say to the universe after stubbing my toe in the dark:',
model_settings=GeminiModelSettings(
model_settings=GoogleModelSettings(
temperature=0.0, # general model settings can also be specified
gemini_safety_settings=[
{
Expand Down
20 changes: 0 additions & 20 deletions docs/api/models/gemini.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/api/models/google.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# `pydantic_ai.models.google`

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

## Setup

For details on how to set up authentication with this model, see [model configuration for Google](../../models/google.md).
Expand Down
2 changes: 0 additions & 2 deletions docs/api/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

::: pydantic_ai.providers.google

::: pydantic_ai.providers.google_vertex

::: pydantic_ai.providers.openai

::: pydantic_ai.providers.deepseek
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
"""
```

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.
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.
2. Register a static [system prompt](agents.md#system-prompts) using a keyword argument to the agent.
3. [Run the agent](agents.md#running-agents) synchronously, conducting a conversation with the LLM.

Expand Down
4 changes: 2 additions & 2 deletions docs/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The situation is different for certain models:

- [`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.

- [`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.
- [`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.

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:

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

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].

- [`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.
- [`GoogleModel`][pydantic_ai.models.google.GoogleModel] on GLA: YouTube video URLs are sent directly in the request to the model.
263 changes: 0 additions & 263 deletions docs/models/gemini.md

This file was deleted.

11 changes: 11 additions & 0 deletions docs/models/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ agent = Agent(model)

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

This interface has a number of advantages over the Generative Language API:

1. The VertexAI API comes with more enterprise readiness guarantees.
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.
3. If you're running Pydantic AI inside GCP, you don't need to set up authentication, it should "just work".
4. You can decide which region to use, which might be important from a regulatory perspective, and might improve latency.

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.

Whichever way you authenticate, you'll need to have VertexAI enabled in your GCP account.

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.

#### Application Default Credentials
Expand Down
6 changes: 3 additions & 3 deletions docs/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pydantic AI is model-agnostic and has built-in support for multiple model provid

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