Files
/v1/files — upload files for batches and vector stores
Upload a file once and reference it by id — as JSONL input for Batches, or to attach to a Vector store for retrieval. OpenAI-compatible Files API. Files are compressed and encrypted at rest.
Base path: /v1/files
Auth: Bearer token or x-api-key. Requires any inference scope.
Max upload size: 105 MB.
Upload a file
POST /v1/filesmultipart/form-data upload with two fields.
| Field | Type | Required | Description |
|---|---|---|---|
file | file | yes | The file to upload (binary). |
purpose | string | yes | One of the purposes below. |
Purposes
| Purpose | Use |
|---|---|
assistants | Attach to a vector store for retrieval / file search. |
user_data | General-purpose user file. |
vision | Image input. |
batch | JSONL input for the Batch API (validated as JSONL on upload). |
fine-tune | Fine-tuning data. |
evals | Evaluation data. |
Example:
curl https://api.melious.ai/v1/files \
-H "Authorization: Bearer sk-mel-<YOUR_API_KEY>" \
-F purpose="assistants" \
-F file=@handbook.pdfResponse:
{
"id": "file-abc123",
"object": "file",
"bytes": 20413,
"created_at": 1699999999,
"filename": "handbook.pdf",
"purpose": "assistants",
"status": "processed"
}List files
GET /v1/files?purpose=assistants&limit=20&after=<cursor>&order=desc| Query param | Type | Default | Description |
|---|---|---|---|
purpose | string | any | Filter by purpose. |
limit | integer | 20 | Max 100. |
after | string | none | Cursor for pagination. |
order | string | "desc" | "asc" or "desc" by created_at. |
Response:
{
"object": "list",
"data": [ /* file objects */ ],
"has_more": false
}Retrieve file metadata
GET /v1/files/{file_id}Returns the file object (same shape as the upload response). Doesn't return the content — that's a separate endpoint.
Download file content
GET /v1/files/{file_id}/contentReturns the raw bytes (not JSON-wrapped) — the original file you uploaded.
curl https://api.melious.ai/v1/files/file-abc123/content \
-H "Authorization: Bearer sk-mel-<YOUR_API_KEY>" \
-o handbook.pdfFor a batch, use this to pull the output once output_file_id is set on the batch object.
Delete a file
DELETE /v1/files/{file_id}Response:
{
"id": "file-abc123",
"object": "file",
"deleted": true
}Deleting a file does not detach it from vector stores it was already attached to — the store keeps its own indexed copy. Detach via the vector store files endpoint.
Errors
Errors use the OpenAI envelope { "error": { "message", "type", "param", "code" } }.
- 400
invalid_request_error— unsupportedpurpose, malformed multipart, or (forpurpose: "batch") content that fails JSONL validation. - 400 — upload exceeds 105 MB.
- 401
authentication_error— missing or invalid API key. - 404
invalid_request_error— requested file doesn't exist.
Related
Vector stores to attach files for semantic search • Batches for the endpoint that consumes JSONL files • Batch workflow for the end-to-end pattern.