Upload a file
Upload the file withmultipart/form-data.
The live OpenAPI spec requires file and purpose.
file object with an ID such as file-abc123.
Create a vector store
Create a vector store and attach one or more uploaded file IDs.vs_abc123.
Add more files later
You can add more files to an existing vector store without recreating it.status: "in_progress" while indexing runs.
Check the Files and Vector Stores endpoints in the API Reference if you need to poll for status.
List files with pagination
File listings are sorted bycreated_at (newest first by default) and return up to limit items per page.
When has_more is true, pass the last item’s id as after to fetch the next page.
id as before instead: the response is the page immediately preceding that item in the display order.
Files attached in the same batch can share a creation timestamp; the cursor accounts for this, so a full walk returns every file exactly once.
If a cursor’s file no longer exists — for example, it was removed from the vector store while you were paging — the API returns 400 Invalid pagination cursor. Restart the walk from the first page.
Search the vector store
Use semantic search to retrieve the most relevant chunks for a user question.file_id, filename, score data, chunk content, and the file’s current attributes.
Filter search by file attributes
Attributes are file-level key-value metadata — string, number, or boolean values — set when you attach a file (see Add more files later). You can change them after ingest with the update-file endpoint (POST /vector_stores/{vector_store_id}/files/{file_id}); search always evaluates the current values.
Pass filters in the search request to restrict results to files whose attributes match.
A filter is either a comparison — eq, ne, gt, gte, lt, lte, in, nin — or an and/or compound of nested filters.
- A file that does not have the filter’s
keynever matches — including forneandnin. A filter only opts a file in on evidence, never by absence. eqandneare strict equality with no type coercion: the string"2"does not equal the number2.gt,gte,lt, andltecompare numbers only; a non-numeric attribute or filter value fails the comparison.inandnintake an arrayvalueand test whether the file’s attribute is (or is not) one of its elements.andandorcompounds nest to any depth.- On graph stores (GraphRAG), filtering is applied after retrieval, so a filtered search can return fewer than
max_num_resultsmatches.
Typical workflow
Use this sequence for most retrieval setups:- Upload the source file.
- Create a vector store with
file_ids, or attach the file later. - Wait for file processing to complete.
- Search the vector store when you need relevant context.