- Upload a file and get a
file_id - Wait for embeddings to finish processing
- Search with a natural-language query
Step 1 — Upload a file
CallPOST /v1/files to register the file. You get back a file_id and a short-lived signed_url — use the signed URL to PUT the actual bytes directly to storage.
- curl
- Python
- Node.js
Init upload fields
Init upload response
400 on upload.
Step 2 — Wait for embeddings
After the PUT completes, the API automatically chunks and embeds your file (becauseembed: true). You can poll GET /v1/files/{file_id} to watch progress. Give the loop a deadline: if the PUT never lands, upload_status stays pending forever.
- curl
- Python
- Node.js
Status fields
Once
embedding_status is ready, the file is ready to search.
upload_status goes to failed when the uploaded file is over 50 MB or its
Content-Type doesn’t match the mime_type you registered. Register the file again. The status object also
carries file_name, file_type, mime_type, size_bytes, created_at,
updated_at, total_tokens, total_cost_usd and last_error_code.
Step 3 — Search your files
Send a natural-language query toPOST /v1/files/search. The API embeds your query, runs a hybrid search (dense vectors plus keyword matching, merged by reciprocal rank fusion), and returns the raw text with relevance scores. The query embedding is billed to your account like any embedding call.
- curl
- Python
- Node.js
Search fields
Retrieval modes
mode chooses how a search retrieves. The default, vector, is the hybrid search described above — what this endpoint has always done, and what you get when you send no mode at all.
graph and agentic are both off by default, so check with support before you build on either. vector works everywhere.
graph returns what vector returns. Naming it changes nothing about the search itself: linked-document expansion — reaching a document through the links of one that already matched — runs on any search not narrowed with file_ids, whenever the deployment has it enabled, named or not. Sending mode: "graph" only asks the API to confirm it is enabled and refuse if it is not, instead of serving a plain search that looks identical. It embeds nothing, so it adds nothing to what the search costs. The check is on the feature, not on your data: graph succeeds on a corpus with no links at all, and on a search narrowed with file_ids, which takes no hop.
agentic bills one query embedding per pass, not one per request, so it is the only mode that changes what a search costs. How many passes run, and how long the loop may take, are deployment limits rather than request parameters. Passes after the first fill at most half of your top_k, so top_k: 1 leaves no room for a second pass and runs exactly one.
Each pass writes its own embedding event under the request’s request_id, so one agentic search shows up as several events in the usage API. A later pass can fail without failing the search — you still get 200 with whatever was already found. A pass whose query embedding fails records an error event. A pass that fails after its embed is billed and recorded as a success, so the search looks clean and simply returned less.
Read results in the order given, not by score. Linked and follow-up chunks take their slots at the tail, displacing the lowest-ranked direct hits, and each pass scores its own query — so the scores from two passes are not comparable. Sorting the returned list by score interleaves them and can promote a chunk that lost on similarity. Nothing is displaced only where the first pass leaves at least as many slots free as the tail takes — a thinner first pass still loses its lowest hits, and a very thin one can leave the tail as most of what comes back.
Every mode returns the same response shape, and none of them report how many passes ran.
A mode the deployment has not enabled is refused rather than quietly downgraded — 400:
A deployment that predates
mode ignores the field instead of refusing it, and a 200
cannot tell you which happened — graph returns an ordinary search by design. To find
out whether a deployment has the parameter at all, send a value that cannot be valid:
"mode": "none-such" is a 422 validation_error where the field exists, and a plain
200 where it does not. The 422 costs nothing; the 200 is an ordinary billed
search — one query embedding, priced on the query text — so keep the probe query short.
Lowering top_k does not make it cheaper.Search response
End-to-end: RAG chat
Combine search results with a chat completion to answer questions from your documents.- Python
- Node.js
Filtering by metadata
Tag files at upload time and filter at search time — useful when you have documents from different departments, clients, or time periods.Re-triggering embeddings
Ifembed was set to false at upload time, or if embedding failed, you can kick it off manually:
202 with a per-file status:
"wait": true to block until all embeddings finish (useful for small files in scripts).
Rules, per file:
file_idstakes 1 to 100 ids.- The file’s
upload_statusmust beready. - A file that is already embedded comes back as
completed; one still queued or processing comes back asprocessing. - After a failed embedding, the same file can’t be re-queued for 30 minutes. The entry comes back with
embedding_status: "error"and anerrorsaying when to retry.
List your files
files (array of file status objects), total, limit, and offset.
Delete a file
CallDELETE /v1/files/{file_id} to remove a file. Its chunks are dropped from
the search index and the stored file is deleted, so the document stops appearing
in POST /v1/files/search results.
- curl
- Python
- Node.js
204 No Content with an empty body — there is no
JSON response to parse.
Deleting is idempotent, so retrying is always safe and converges on a full
delete. Treat a file as deleted only once you have received a
204 — if a call
fails, repeat it until it succeeds rather than assuming it partly applied.
Usage records that reference the file stay available afterwards, so your billing
history and usage queries remain complete.