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
+116-2Lines changed: 116 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Pydantic AI supports the following built-in tools:
12
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
+
-**[`FileSearchTool`][pydantic_ai.builtin_tools.FileSearchTool]**: Enables agents to search through uploaded files using vector search (RAG)
15
16
16
17
These tools are passed to the agent via the `builtin_tools` parameter and are executed by the model provider's infrastructure.
**Note:** For OpenAI, `auto` lets the model select the value.
371
391
372
392
## Web Fetch Tool
373
393
@@ -672,6 +692,100 @@ _(This example is complete, it can be run "as is")_
672
692
|`description`| ✅ | ❌ |
673
693
|`headers`| ✅ | ❌ |
674
694
695
+
## File Search Tool
696
+
697
+
The [`FileSearchTool`][pydantic_ai.builtin_tools.FileSearchTool] enables your agent to search through uploaded files using vector search, providing a fully managed Retrieval-Augmented Generation (RAG) system. This tool handles file storage, chunking, embedding generation, and context injection into prompts.
698
+
699
+
### Provider Support
700
+
701
+
| Provider | Supported | Notes |
702
+
|----------|-----------|-------|
703
+
| OpenAI Responses | ✅ | Full feature support. Requires files to be uploaded to vector stores via the [OpenAI Files API](https://platform.openai.com/docs/api-reference/files). To include search results on the [`BuiltinToolReturnPart`][pydantic_ai.messages.BuiltinToolReturnPart] available via [`ModelResponse.builtin_tool_calls`][pydantic_ai.messages.ModelResponse.builtin_tool_calls], enable the [`OpenAIResponsesModelSettings.openai_include_file_search_results`][pydantic_ai.models.openai.OpenAIResponsesModelSettings.openai_include_file_search_results][model setting](agents.md#model-run-settings). |
704
+
| Google (Gemini) | ✅ | Requires files to be uploaded via the [Gemini Files API](https://ai.google.dev/gemini-api/docs/files). Files are automatically deleted after 48 hours. Supports up to 2 GB per file and 20 GB per project. 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. |
705
+
|| Google (Vertex AI) | ❌ | Not supported |
706
+
| Anthropic | ❌ | Not supported |
707
+
| Groq | ❌ | Not supported |
708
+
| OpenAI Chat Completions | ❌ | Not supported |
709
+
| Bedrock | ❌ | Not supported |
710
+
| Mistral | ❌ | Not supported |
711
+
| Cohere | ❌ | Not supported |
712
+
| HuggingFace | ❌ | Not supported |
713
+
| Outlines | ❌ | Not supported |
714
+
715
+
### Usage
716
+
717
+
#### OpenAI Responses
718
+
719
+
With OpenAI, you need to first [upload files to a vector store](https://platform.openai.com/docs/assistants/tools/file-search), then reference the vector store IDs when using the `FileSearchTool`.
result =await agent.run('What information is in my documents about pydantic?')
746
+
print(result.output)
747
+
#> Based on your documents, Pydantic is a data validation library for Python...
748
+
749
+
asyncio.run(main())
750
+
```
751
+
752
+
#### Google (Gemini)
753
+
754
+
With Gemini, you need to first [create a file search store via the Files API](https://ai.google.dev/gemini-api/docs/files), then reference the file search store names.
0 commit comments