Skip to content
Last updated

File search lets your AI assistant query and retrieve information from documents you've uploaded. The assistant can find relevant passages, answer questions about file contents, and cite sources from your knowledge base.

How It Works

  1. Upload files to a vector store using the Files API
  2. Attach the vector store to your assistant
  3. When the user asks questions, the model automatically searches the files and incorporates relevant content into its response
{
 "organization_id": "org_your_org_id",
 "assistant_id": "asst_abc123",
 "tools": [{"type": "file_search"}],
 "inputs": [{"role": "user", "content": "What does the Q3 report say about revenue?"}]
}

Tool Modes

ModeBehavior
autoModel decides when to search (recommended)
onAlways search files before responding
offDisable file search

Supported File Types

FormatExtension
PDF.pdf
Word documents.docx, .doc
Text.txt, .md
Code.py, .js, .ts, .java, and more
CSV.csv

Response Structure

When file search is used, the response includes file_search_call output items:

{
 "output": [
 {
 "type": "file_search_call",
 "id": "fs_abc123",
 "status": "completed",
 "results": [
 {
 "file_id": "file_xyz789",
 "filename": "q3-report.pdf",
 "score": 0.94,
 "text": "Q3 revenue increased 23% year-over-year..."
 }
 ]
 },
 {
 "type": "message",
 "role": "assistant",
 "content": [{"type": "output_text", "text": "According to the Q3 report, revenue..."}]
 }
 ]
}
import requests

# Upload a file
with open("report.pdf", "rb") as f:
 response = requests.post(
 "https://api.aitronos.com/v1/files",
 headers={"X-API-Key": os.environ["FREDDY_API_KEY"]},
 files={"file": f},
 data={
 "organization_id": "org_your_org_id",
 "purpose": "assistants",
 },
 )
file_id = response.json()["id"]

Then attach the file to a vector store and link the vector store to your assistant. See the Files API and Vector Stores API for details.