Skip to main content

Upload a file

Upload the file with multipart/form-data. The live OpenAPI spec requires file and purpose. Note: multipart file parts must include a nonblank filename. The lowercase WHATWG placeholder filename "blob" is treated as missing.
The response returns a file object with an ID such as file-abc123.

List files with pagination

File listings are sorted by created_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.
To page backwards, pass an item’s 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.

Use uploaded files

Index documents in Vector stores, provide Document inputs, or prepare evals.