1
1
# ` pydantic_ai.models.vertexai `
2
2
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
+
3
8
Custom interface to the ` *-aiplatform.googleapis.com ` API for Gemini models.
4
9
5
10
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
19
24
20
25
With the default google project already configured in your environment using "application default credentials":
21
26
22
- ``` python {title="vertex_example_env.py"}
27
+ ``` python {title="vertex_example_env.py", test="skip" }
23
28
from pydantic_ai import Agent
24
29
from pydantic_ai.models.vertexai import VertexAIModel
25
30
26
- model = VertexAIModel(' gemini-1.5-flash' )
31
+ model = VertexAIModel(' gemini-1.5-flash' ) # (1)!
27
32
agent = Agent(model)
28
33
result = agent.run_sync(' Tell me a joke.' )
29
34
print (result.data)
30
35
# > Did you hear about the toothpaste scandal? They called it Colgate.
31
36
```
32
37
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
+
33
41
Or using a service account JSON file:
34
42
35
- ``` python {title="vertex_example_service_account.py"}
43
+ ``` python {title="vertex_example_service_account.py" test="skip" }
36
44
from pydantic_ai import Agent
37
45
from pydantic_ai.models.vertexai import VertexAIModel
38
46
39
- model = VertexAIModel(
47
+ model = VertexAIModel( # (1)!
40
48
' gemini-1.5-flash' ,
41
49
service_account_file = ' path/to/service-account.json' ,
42
50
)
@@ -46,4 +54,7 @@ print(result.data)
46
54
# > Did you hear about the toothpaste scandal? They called it Colgate.
47
55
```
48
56
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
+
49
60
::: pydantic_ai.models.vertexai
0 commit comments