You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/builtin-tools.md
+51-8Lines changed: 51 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Pydantic AI supports the following built-in tools:
9
9
-**[`WebSearchTool`][pydantic_ai.builtin_tools.WebSearchTool]**: Allows agents to search the web
10
10
-**[`CodeExecutionTool`][pydantic_ai.builtin_tools.CodeExecutionTool]**: Enables agents to execute code in a secure environment
11
11
-**[`ImageGenerationTool`][pydantic_ai.builtin_tools.ImageGenerationTool]**: Enables agents to generate images
12
-
-**[`UrlContextTool`][pydantic_ai.builtin_tools.UrlContextTool]**: Enables agents to pull URL contents into their context
12
+
-**[`WebFetchTool`][pydantic_ai.builtin_tools.WebFetchTool]**: Enables agents to fetch web pages
13
13
-**[`MemoryTool`][pydantic_ai.builtin_tools.MemoryTool]**: Enables agents to use memory
14
14
-**[`MCPServerTool`][pydantic_ai.builtin_tools.MCPServerTool]**: Enables agents to use remote MCP servers with communication handled by the model provider
15
15
@@ -306,18 +306,18 @@ For more details, check the [API documentation][pydantic_ai.builtin_tools.ImageG
306
306
|`quality`| ✅ | ❌ |
307
307
|`size`| ✅ | ❌ |
308
308
309
-
## URL Context Tool
309
+
## Web Fetch Tool
310
310
311
-
The [`UrlContextTool`][pydantic_ai.builtin_tools.UrlContextTool] enables your agent to pull URL contents into its context,
311
+
The [`WebFetchTool`][pydantic_ai.builtin_tools.WebFetchTool] enables your agent to pull URL contents into its context,
312
312
allowing it to pull up-to-date information from the web.
313
313
314
314
### Provider Support
315
315
316
316
| Provider | Supported | Notes |
317
317
|----------|-----------|-------|
318
-
| Google | ✅ | No [`BuiltinToolCallPart`][pydantic_ai.messages.BuiltinToolCallPart] or [`BuiltinToolReturnPart`][pydantic_ai.messages.BuiltinToolReturnPart] is currently generated; please submit an issue if you need this. Using built-in tools and function tools (including [output tools](output.md#tool-output)) at the same time is not supported; to use structured output, use [`PromptedOutput`](output.md#prompted-output) instead. |
318
+
| Anthropic | ✅ | Full feature support. Uses Anthropic's [Web Fetch Tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-fetch-tool) internally to retrieve URL contents. |
319
+
| Google | ✅ | No parameter support. The limits are fixed at 20 URLs per request with a maximum of 34MB per URL. Using built-in tools and function tools (including [output tools](output.md#tool-output)) at the same time is not supported; to use structured output, use [`PromptedOutput`](output.md#prompted-output) instead. |
319
320
| OpenAI | ❌ ||
320
-
| Anthropic | ❌ ||
321
321
| Groq | ❌ ||
322
322
| Bedrock | ❌ ||
323
323
| Mistral | ❌ ||
@@ -327,10 +327,10 @@ allowing it to pull up-to-date information from the web.
'Compare the documentation at https://ai.pydantic.dev and https://docs.pydantic.dev'
363
+
)
364
+
print(result.output)
365
+
"""
366
+
Both sites provide comprehensive documentation for Pydantic projects. ai.pydantic.dev focuses on PydanticAI, a framework for building AI agents, while docs.pydantic.dev covers Pydantic, the data validation library. They share similar documentation styles and both emphasize type safety and developer experience.
367
+
"""
368
+
```
369
+
370
+
_(This example is complete, it can be run "as is")_
371
+
372
+
#### Provider Support
373
+
374
+
| Parameter | Anthropic | Google |
375
+
|-----------|-----------|--------|
376
+
|`max_uses`| ✅ | ❌ |
377
+
|`allowed_domains`| ✅ | ❌ |
378
+
|`blocked_domains`| ✅ | ❌ |
379
+
|`enable_citations`| ✅ | ❌ |
380
+
|`max_content_tokens`| ✅ | ❌ |
381
+
382
+
!!! note "Anthropic Domain Filtering"
383
+
With Anthropic, you can only use either `blocked_domains` or `allowed_domains`, not both.
384
+
342
385
## Memory Tool
343
386
344
387
The [`MemoryTool`][pydantic_ai.builtin_tools.MemoryTool] enables your agent to use memory.
Copy file name to clipboardExpand all lines: docs/models/openai.md
+1-29Lines changed: 1 addition & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -233,7 +233,7 @@ agent = Agent(model)
233
233
```
234
234
235
235
Various providers also have their own provider classes so that you don't need to specify the base URL yourself and you can use the standard `<PROVIDER>_API_KEY` environment variable to set the API key.
236
-
When a provider has its own provider class, you can use the `Agent("<provider>:<model>")` shorthand, e.g. `Agent("deepseek:deepseek-chat")` or `Agent("openrouter:google/gemini-2.5-pro-preview")`, instead of building the `OpenAIChatModel` explicitly. Similarly, you can pass the provider name as a string to the `provider` argument on `OpenAIChatModel` instead of building instantiating the provider class explicitly.
236
+
When a provider has its own provider class, you can use the `Agent("<provider>:<model>")` shorthand, e.g. `Agent("deepseek:deepseek-chat")` or `Agent("moonshotai:kimi-k2-0711-preview")`, instead of building the `OpenAIChatModel` explicitly. Similarly, you can pass the provider name as a string to the `provider` argument on `OpenAIChatModel` instead of building instantiating the provider class explicitly.
237
237
238
238
#### Model Profile
239
239
@@ -385,34 +385,6 @@ agent = Agent(model)
385
385
...
386
386
```
387
387
388
-
### OpenRouter
389
-
390
-
To use [OpenRouter](https://openrouter.ai), first create an API key at [openrouter.ai/keys](https://openrouter.ai/keys).
391
-
392
-
You can set the `OPENROUTER_API_KEY` environment variable and use [`OpenRouterProvider`][pydantic_ai.providers.openrouter.OpenRouterProvider] by name:
To use [Vercel's AI Gateway](https://vercel.com/docs/ai-gateway), first follow the [documentation](https://vercel.com/docs/ai-gateway) instructions on obtaining an API key or OIDC token.
OpenRouter has an [app attribution](https://openrouter.ai/docs/app-attribution) feature to track your application in their public ranking and analytics.
42
+
43
+
You can pass in an `app_url` and `app_title` when initializing the provider to enable app attribution.
44
+
45
+
```python
46
+
from pydantic_ai.providers.openrouter import OpenRouterProvider
47
+
48
+
provider=OpenRouterProvider(
49
+
api_key='your-openrouter-api-key',
50
+
app_url='https://your-app.com',
51
+
app_title='Your App',
52
+
),
53
+
...
54
+
```
55
+
56
+
## Model Settings
57
+
58
+
You can customize model behavior using [`OpenRouterModelSettings`][pydantic_ai.models.openrouter.OpenRouterModelSettings]:
59
+
60
+
```python
61
+
from pydantic_ai import Agent
62
+
from pydantic_ai.models.openrouter import OpenRouterModel, OpenRouterModelSettings
To enable thinking, use the [`OpenRouterModelSettings.openrouter_reasoning`][pydantic_ai.models.openrouter.OpenRouterModelSettings.openrouter_reasoning][model setting](agents.md#model-run-settings).
150
+
151
+
```python {title="openrouter_thinking_part.py"}
152
+
from pydantic_ai import Agent
153
+
from pydantic_ai.models.openrouter import OpenRouterModel, OpenRouterModelSettings
0 commit comments