Skip to main content
The File Search tool provides direct access to your vector stores, enabling semantic search to find relevant content based on the meaning of your query rather than just keyword matching.

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 ForConsider Alternatives For
  • Simple, factual queries
  • Finding specific documentation
  • Known-item searches
  • Code examples for specific tasks
  • Looking up configurations or settings
  • Complex research questions
  • Multi-faceted analysis
  • Questions requiring synthesis of multiple sources
  • Exploratory research without clear goals

Use Cases for File Search

For complex questions requiring deep research and multiple search iterations, consider using the Agentic Search Tool instead.

Example Queries

Simple Factual Queries

Finding Code Examples

Looking Up Configuration

Advanced Usage

Filtering by Metadata

The filters parameter allows you to narrow search results based on document metadata:
Filters dramatically improve search relevance by narrowing the search space. Always use them when you know specific attributes of the documents you’re looking for.

Multi-Store Searching

Searching across multiple vector stores allows you to find information across different document collections:

Best Practices

More specific queries yield better results than vague ones.Good Example:
Less Effective:
The vector search works best with natural language queries rather than keyword lists.Good Example:
Less Effective:
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

FeatureFile SearchAgentic Search
Query complexitySimpleComplex
Search iterationsSingleMultiple
Response timeFastSlower
Result qualityDirect matchesComprehensive
Best forKnown-item searchesResearch questions

File Search vs. Agentic Search

Think Tool

For logging thoughts and reasoning processes

Agentic Search Tool

For AI-guided iterative searches for complex questions