Skip to content

Commit 891571f

Browse files
Kludexdmontagu
andauthored
Add Providers API (#1013)
Co-authored-by: David Montague <[email protected]>
1 parent 9894a26 commit 891571f

29 files changed

+1123
-218
lines changed

docs/api/models/vertexai.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# `pydantic_ai.models.vertexai`
22

3+
!!! warning "Deprecated"
4+
The `VertexAIModel` is deprecated. You can use the
5+
[`GoogleVertexProvider`][pydantic_ai.providers.google_vertex.GoogleVertexProvider] to authenticate with the Vertex AI API
6+
and then use the [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel] to use the Gemini API.
7+
38
Custom interface to the `*-aiplatform.googleapis.com` API for Gemini models.
49

510
This model inherits from [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel] with just the URL and auth method
@@ -19,24 +24,27 @@ see [model configuration for Gemini via VertexAI](../../models.md#gemini-via-ver
1924

2025
With the default google project already configured in your environment using "application default credentials":
2126

22-
```python {title="vertex_example_env.py"}
27+
```python {title="vertex_example_env.py", test="skip"}
2328
from pydantic_ai import Agent
2429
from pydantic_ai.models.vertexai import VertexAIModel
2530

26-
model = VertexAIModel('gemini-1.5-flash')
31+
model = VertexAIModel('gemini-1.5-flash') # (1)!
2732
agent = Agent(model)
2833
result = agent.run_sync('Tell me a joke.')
2934
print(result.data)
3035
#> Did you hear about the toothpaste scandal? They called it Colgate.
3136
```
3237

38+
1. The `VertexAIModel` is deprecated, you should use the [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel]
39+
with the [`GoogleVertexProvider`][pydantic_ai.providers.google_vertex.GoogleVertexProvider] instead.
40+
3341
Or using a service account JSON file:
3442

35-
```python {title="vertex_example_service_account.py"}
43+
```python {title="vertex_example_service_account.py" test="skip"}
3644
from pydantic_ai import Agent
3745
from pydantic_ai.models.vertexai import VertexAIModel
3846

39-
model = VertexAIModel(
47+
model = VertexAIModel( # (1)!
4048
'gemini-1.5-flash',
4149
service_account_file='path/to/service-account.json',
4250
)
@@ -46,4 +54,7 @@ print(result.data)
4654
#> Did you hear about the toothpaste scandal? They called it Colgate.
4755
```
4856

57+
1. The `VertexAIModel` is deprecated, you should use the [`GeminiModel`][pydantic_ai.models.gemini.GeminiModel]
58+
with the [`GoogleVertexProvider`][pydantic_ai.providers.google_vertex.GoogleVertexProvider] instead.
59+
4960
::: pydantic_ai.models.vertexai

docs/api/providers.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# `pydantic_ai.providers`
2+
3+
::: pydantic_ai.providers.Provider
4+
5+
::: pydantic_ai.providers.google_vertex
6+
7+
::: pydantic_ai.providers.openai
8+
9+
::: pydantic_ai.providers.deepseek

0 commit comments

Comments
 (0)