Response API - File Search
The file search functionality using the OpenAI Responses API in the Compass platform enables users to search the files and content within their authorized projects.
A File Search tool that lets AI models search through your uploaded documents to answer questions with contextual information from uploaded and processed files.
Core File Search Parameters
Parameter | Required | Type | Description |
model |
Yes | string | Model to use (e.g., "gpt-4o", "gpt-4o-mini") |
input |
Yes | string/array | User query or conversation history |
tools |
Yes | array | Must include file_search tool configuration |
|
Yes | string | Must be file_search |
|
Yes | array |
Array of authorized vector store IDs |
|
No | integer |
Maximum results per search (1-50, default: 20) |
|
No | object |
Search ranking configuration |
|
No | string |
"auto" |
|
No | float |
Minimum relevance score (0.0-1.0) |
Examples
1. Basic File Search Request
# Environment variables
export BASE_URL="https://<compass-url>/v1"
export API_KEY="api-key"
# Basic file search within project scope
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key: $API_KEY" \
-d '{
"model": "gpt-4o-mini",
"input": "What are the key findings in our Q4 financial reports?",
"tools": [
{
"type": "file_search",
"vector_store_ids": ["vs_proj123_financial", "vs_proj123_reports"]
}
],
"metadata": {
"user_id": "user_456",
"project_id": "proj_123",
"request_type": "file_search"
}
}'
2. Advanced File Search with Ranking Options
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key: $API_KEY" \
-d '{
"model": "gpt-4o",
"input": "Find all mentions of machine learning algorithms in our research papers",
"tools": [
{
"type": "file_search",
"vector_store_ids": ["vs_proj123_research"],
"max_num_results": 10,
"ranking_options": {
"ranker": "default_2024_08_21",
"score_threshold": 0.7
}
}
],
"temperature": 0.3,
"metadata": {
"user_id": "user_789",
"project_id": "proj_123",
"search_category": "research"
}
}'
3. Multi-Turn Conversation with File Search
# First request
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key: $API_KEY" \
-d '{
"model": "gpt-4o-mini",
"input": "Summarize our product roadmap documents",
"tools": [
{
"type": "file_search",
"vector_store_ids": ["vs_proj456_roadmap"]
}
],
"metadata": {
"user_id": "user_101",
"project_id": "proj_456"
}
}'
# Continue conversation using previous_response_id
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key $API_KEY" \
-d '{
"model": "gpt-4o-mini",
"input": "What are the timeline dependencies mentioned?",
"tools": [
{
"type": "file_search",
"vector_store_ids": ["vs_proj456_roadmap"]
}
],
"previous_response_id": "resp_abc123def456",
"metadata": {
"user_id": "user_101",
"project_id": "proj_456"
}
}'
4. Multiple File Search Tools in Single Request
You can include multiple file_search
tools with different vector stores and configurations in the same request for comprehensive cross-document analysis.
# Multiple file search tools with different configurations
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key $API_KEY" \
-d '{
"model": "gpt-4o",
"input": "How do our financial projections align with our product roadmap and marketing strategy?",
"tools": [
{
"type": "file_search",
"vector_store_ids": ["vs_proj123_financial"],
"max_num_results": 10,
"ranking_options": {
"score_threshold": 0.8
}
},
{
"type": "file_search",
"vector_store_ids": ["vs_proj123_roadmap"],
"max_num_results": 15,
"ranking_options": {
"score_threshold": 0.7
}
},
{
"type": "file_search",
"vector_store_ids": ["vs_proj123_marketing"],
"max_num_results": 12,
"ranking_options": {
"score_threshold": 0.75
}
}
],
"metadata": {
"user_id": "user_456",
"project_id": "proj_123",
"request_type": "multi_source_search",
"search_categories": "financial,roadmap,marketing"
}
}'
# Alternative: Single tool with multiple vector stores
curl -X POST $BASE_URL/responses \
-H "Content-Type: application/json" \
-H "api-key $API_KEY" \
-d '{
"model": "gpt-4o",
"input": "Analyze our complete business strategy across all departments",
"tools": [
{
"type": "file_search",
"vector_store_ids": [
"vs_proj123_financial",
"vs_proj123_roadmap",
"vs_proj123_marketing",
"vs_proj123_hr_docs"
],
"max_num_results": 25
}
],
"metadata": {
"user_id": "user_789",
"project_id": "proj_123",
"request_type": "comprehensive_search"
}
}'