- Reusing the same document across many API operations (datasource creation, batch jobs, downloads) without uploading it again.
- Grounding agents and deployments with knowledge base datasources.
- Storing JSONL datasets as files for batch jobs.
- Giving code interpreter tools access to project documents.
Upload a file once with the Files API (
/v2/files), then reuse it across Orq.ai: create a knowledge base datasource from it, feed a batch job, or download its content through a presigned URL.
For sending inline image, PDF, or audio content directly in a request, see Multimodal inputs and generation.
Upload
Create a file with a JSON body or multipart form data.
Download
Get a presigned URL valid for one hour.
Knowledge base
Turn an uploaded file into a datasource for retrieval.
Manage
List, update metadata, and delete files.
Upload a file
POST /v2/files accepts a JSON body or multipart/form-data.
JSON body fields:
The upload request uses
filename; the response file object and the PATCH update use file_name.
For multipart uploads, send the file in the file form field and set purpose and project_id as additional form fields. The MIME type is read from the file part’s Content-Type header.
Purposes
The REST API accepts lowercase purpose values on input (for example
retrieval); the response object returns the prefixed form (for example FILE_PURPOSE_RETRIEVAL). The SDKs use the prefixed form for both input and output.
The file object
A successful upload returns the file object under afile key:
Keep the
file_id for later operations: retrieval, metadata updates, downloads, and datasource creation.
Files and model calls
Model calls receive file content inline. Images and PDFs are passed as public URLs or base64 data URIs in the message content array. See Multimodal inputs and generation for the exact content parts. To use an uploaded file in a model call, index it into a knowledge base and attach the knowledge base to the deployment or agent. See From file to knowledge base and Run Agents: Attach Files.Download file content
GET /v2/files/{file_id_or_path}/content returns a presigned URL for downloading the file content.
Presigned URLs expire after one hour. Call the endpoint again to get a fresh URL.
List, update, and delete files
List files:GET /v2/files. Results are sorted by file_id in ascending order, so the most recently created files appear last. Page through with limit (default 10, maximum 200). Set starting_after to the file_id of the last item of the previous page, or ending_before to the first item. Filter by purpose or project_id.
Retrieve a file: GET /v2/files/{file_id} returns the file object.
Update metadata: PATCH /v2/files/{file_id} updates the file name. The body accepts file_name; content cannot be changed after upload.
Delete a file: DELETE /v2/files/{file_id} permanently deletes the file record and its stored content. Deletion cannot be undone.
Supported types and limits
Files with multiple filename extensions are rejected. The stored MIME type comes from the declared
content_type or the filename extension.
Data handling and lifecycle
- Project scope: files belong to the project they were created in. An API key can only access files in the projects it is authorized for.
- Persistence: file content persists until explicitly deleted with
DELETE /v2/files/{file_id}. There is no automatic expiry. - Presigned URLs: download links expire after one hour and can be regenerated at any time.
- Cleanup: delete files that are no longer referenced. For long-running agents and deployments, delete superseded documents after the consuming run finishes to avoid unbounded storage.
From file to knowledge base
The file-based knowledge base flow uploads a document, then points a datasource at the resultingfile_id. Orq.ai chunks and indexes the file automatically.
- Upload the document with
POST /v2/filesand save thefile_id. - Create a datasource with
POST /v2/knowledge/{knowledge_id}/datasources, passingfile_idanddisplay_name. - Attach the knowledge base to a deployment or agent to ground responses in the indexed content.