Skip to content

Commit 0e3f1d9

Browse files
samuelcolvinDouweM
andauthored
Fix markdown in builtin tools api docs (#2826)
Co-authored-by: Douwe Maan <[email protected]>
1 parent f8e6e0f commit 0e3f1d9

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ node_modules/
2020
.coverage*
2121
/test_tmp/
2222
.mcp.json
23+
.claude/

docs/builtin-tools.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,38 @@ making it ideal for queries that require up-to-date data.
2626

2727
| Provider | Supported | Notes |
2828
|----------|-----------|-------|
29-
| OpenAI || Full feature support |
29+
| OpenAI Responses || Full feature support |
3030
| Anthropic || Full feature support |
3131
| Groq || Limited parameter support. To use web search capabilities with Groq, you need to use the [compound models](https://console.groq.com/docs/compound). |
3232
| Google || No parameter support. Google does not support using built-in tools and user tools (including [output tools](output.md#tool-output)) at the same time. To use structured output, use [`PromptedOutput`](output.md#prompted-output) instead. |
33+
| OpenAI Chat Completions || Not supported |
3334
| Bedrock || Not supported |
3435
| Mistral || Not supported |
3536
| Cohere || Not supported |
3637
| HuggingFace || Not supported |
3738

3839
### Usage
3940

40-
```py title="web_search_basic.py"
41+
```py title="web_search_anthropic.py"
4142
from pydantic_ai import Agent, WebSearchTool
4243

4344
agent = Agent('anthropic:claude-sonnet-4-0', builtin_tools=[WebSearchTool()])
4445

4546
result = agent.run_sync('Give me a sentence with the biggest news in AI this week.')
46-
# > Scientists have developed a universal AI detector that can identify deepfake videos.
47+
print(result.output)
48+
#> Scientists have developed a universal AI detector that can identify deepfake videos.
49+
```
50+
51+
With OpenAI, you must use their responses API to access the web search tool.
52+
53+
```py title="web_search_openai.py"
54+
from pydantic_ai import Agent, WebSearchTool
55+
56+
agent = Agent('openai-responses:gpt-4.1', builtin_tools=[WebSearchTool()])
4757

58+
result = agent.run_sync('Give me a sentence with the biggest news in AI this week.')
59+
print(result.output)
60+
#> Scientists have developed a universal AI detector that can identify deepfake videos.
4861
```
4962

5063
### Configuration Options

pydantic_ai_slim/pydantic_ai/builtin_tools.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class WebSearchTool(AbstractBuiltinTool):
2626
The parameters that PydanticAI passes depend on the model, as some parameters may not be supported by certain models.
2727
2828
Supported by:
29+
2930
* Anthropic
30-
* OpenAI
31+
* OpenAI Responses
3132
* Groq
3233
* Google
3334
"""
@@ -36,15 +37,17 @@ class WebSearchTool(AbstractBuiltinTool):
3637
"""The `search_context_size` parameter controls how much context is retrieved from the web to help the tool formulate a response.
3738
3839
Supported by:
39-
* OpenAI
40+
41+
* OpenAI Responses
4042
"""
4143

4244
user_location: WebSearchUserLocation | None = None
4345
"""The `user_location` parameter allows you to localize search results based on a user's location.
4446
4547
Supported by:
48+
4649
* Anthropic
47-
* OpenAI
50+
* OpenAI Responses
4851
"""
4952

5053
blocked_domains: list[str] | None = None
@@ -53,8 +56,9 @@ class WebSearchTool(AbstractBuiltinTool):
5356
With Anthropic, you can only use one of `blocked_domains` or `allowed_domains`, not both.
5457
5558
Supported by:
56-
* Anthropic (https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering)
57-
* Groq (https://console.groq.com/docs/agentic-tooling#search-settings)
59+
60+
* Anthropic, see <https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering>
61+
* Groq, see <https://console.groq.com/docs/agentic-tooling#search-settings>
5862
"""
5963

6064
allowed_domains: list[str] | None = None
@@ -63,14 +67,16 @@ class WebSearchTool(AbstractBuiltinTool):
6367
With Anthropic, you can only use one of `blocked_domains` or `allowed_domains`, not both.
6468
6569
Supported by:
66-
* Anthropic (https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering)
67-
* Groq (https://console.groq.com/docs/agentic-tooling#search-settings)
70+
71+
* Anthropic, see <https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool#domain-filtering>
72+
* Groq, see <https://console.groq.com/docs/agentic-tooling#search-settings>
6873
"""
6974

7075
max_uses: int | None = None
7176
"""If provided, the tool will stop searching the web after the given number of uses.
7277
7378
Supported by:
79+
7480
* Anthropic
7581
"""
7682

@@ -79,8 +85,9 @@ class WebSearchUserLocation(TypedDict, total=False):
7985
"""Allows you to localize search results based on a user's location.
8086
8187
Supported by:
88+
8289
* Anthropic
83-
* OpenAI
90+
* OpenAI Responses
8491
"""
8592

8693
city: str
@@ -100,8 +107,9 @@ class CodeExecutionTool(AbstractBuiltinTool):
100107
"""A builtin tool that allows your agent to execute code.
101108
102109
Supported by:
110+
103111
* Anthropic
104-
* OpenAI
112+
* OpenAI Responses
105113
* Google
106114
"""
107115

@@ -110,5 +118,6 @@ class UrlContextTool(AbstractBuiltinTool):
110118
"""Allows your agent to access contents from URLs.
111119
112120
Supported by:
121+
113122
* Google
114123
"""

0 commit comments

Comments
 (0)