What It Is
The File Search tool connects directly to your vector stores, allowing you to search through your document collections using semantic understanding rather than just keyword matching. It’s designed for immediate results on simple, well-defined queries.Query: “What is the maximum connection timeout value?”
Results:
From: config/database.md
The maximum connection timeout value is 300 seconds (5 minutes). This can be configured in the database settings with the
DB_CONNECTION_TIMEOUT environment variable. For high-latency networks, consider increasing this value.File Search Tool in Action
Configuration
Basic configuration requires a query parameter:Configuration Parameters
Response Format
The response includes relevant content chunks with metadata:When to Use It
The File Search tool excels in specific scenarios where direct, immediate access to information is required.| Recommended For | Consider Alternatives For |
|---|---|
|
|
Use Cases for File Search
Example Queries
Simple Factual Queries
Finding Code Examples
Looking Up Configuration
Advanced Usage
Filtering by Metadata
Thefilters parameter allows you to narrow search results based on document metadata:
Multi-Store Searching
Searching across multiple vector stores allows you to find information across different document collections:Best Practices
Craft Specific Queries
Craft Specific Queries
More specific queries yield better results than vague ones.Good Example:Less Effective:
Use Natural Language
Use Natural Language
The vector search works best with natural language queries rather than keyword lists.Good Example:Less Effective:
Combine with Filters
Combine with Filters
For the most precise results, combine semantic search with metadata filters.
Integration Examples
Tool Usage with OpenAI Models
The file_search tool automatically performs the search and provides the results to the AI model in the same request. This creates a seamless RAG experience where the model can access and use the information without additional API calls.
GitHub Example Implementation
For a complete working example of the File Search tool, check out this Python example on GitHub. This example demonstrates:- Uploading files and creating vector stores
- Setting up and configuring the FileSearchTool
- Performing direct searches with different parameters
- Comparing results with the Agentic Search approach
- Integration with the OpenAI Agents SDK
Using with Custom Search Logic
For applications that need more control over the search process, you can implement custom search logic:Comparing with Other Tools
| Feature | File Search | Agentic Search |
|---|---|---|
| Query complexity | Simple | Complex |
| Search iterations | Single | Multiple |
| Response time | Fast | Slower |
| Result quality | Direct matches | Comprehensive |
| Best for | Known-item searches | Research questions |
File Search vs. Agentic Search
Related Tools
Think Tool
For logging thoughts and reasoning processes
Agentic Search Tool
For AI-guided iterative searches for complex questions