Files

Upload, list, download, and delete files used for fine-tuning, batch jobs, file-parser plugin, and assistants.

Overview

The Files API stores blobs that are referenced by other endpoints. Common use cases:

  • Fine-tuning -- upload JSONL training and validation datasets
  • Batch processing -- upload a JSONL of inputs for asynchronous processing
  • File parser plugin -- upload PDFs, DOCX, XLSX for context augmentation
  • Image edits -- upload PNG sources and masks
  • Audio -- upload large audio files for transcription

Files are stored in AllRoutes-managed encrypted object storage. Each file has a unique file_id that other endpoints reference.

Upload

POST https://api.allroutes.ai/v1/files

Multipart form upload.

FieldTypeRequiredDescription
filefileYesThe file to upload (max 512 MB)
purposestringYesfine-tune, batch, assistants, vision, user_data

Example

curl https://api.allroutes.ai/v1/files \
  -H "Authorization: Bearer allroutes_sk_..." \
  -F purpose=fine-tune \
  -F [email protected]

Response

{
  "id": "file_abc123",
  "object": "file",
  "bytes": 524288,
  "filename": "training.jsonl",
  "purpose": "fine-tune",
  "created_at": 1714000000,
  "status": "processed",
  "status_details": null
}

List

GET https://api.allroutes.ai/v1/files
Query ParamTypeDescription
purposestringFilter by purpose
limitintegerMax results (default: 100, max: 10000)
orderstringasc or desc (default: desc by created_at)
afterstringCursor for pagination
curl "https://api.allroutes.ai/v1/files?purpose=fine-tune&limit=20" \
  -H "Authorization: Bearer allroutes_sk_..."

Retrieve Metadata

GET https://api.allroutes.ai/v1/files/:file_id
curl https://api.allroutes.ai/v1/files/file_abc123 \
  -H "Authorization: Bearer allroutes_sk_..."

Download Contents

GET https://api.allroutes.ai/v1/files/:file_id/content

Returns the raw file bytes. Set the appropriate Accept header if you need a specific content type.

curl https://api.allroutes.ai/v1/files/file_abc123/content \
  -H "Authorization: Bearer allroutes_sk_..." \
  --output training.jsonl

Delete

DELETE https://api.allroutes.ai/v1/files/:file_id
curl -X DELETE https://api.allroutes.ai/v1/files/file_abc123 \
  -H "Authorization: Bearer allroutes_sk_..."

Response

{
  "id": "file_abc123",
  "object": "file",
  "deleted": true
}

Purposes

Each purpose constrains how the file can be used and what validation runs at upload time:

PurposeAccepted FormatsMax SizeValidation
fine-tuneJSONL (chat format)512 MBSchema-validated; line-by-line parsing
batchJSONL512 MBSchema-validated against batch envelope
assistantsMost formats512 MBNone
visionPNG, JPEG, WEBP20 MBImage dimension check
user_dataAny512 MBNone

SDK Examples

Python

# Upload
with open("training.jsonl", "rb") as f:
    upload = client.files.create(file=f, purpose="fine-tune")
print(upload.id)

# List
files = client.files.list(purpose="fine-tune")
for f in files.data:
    print(f"{f.id}: {f.filename} ({f.bytes} bytes)")

# Download
content = client.files.content("file_abc123")
with open("downloaded.jsonl", "wb") as out:
    out.write(content.read())

# Delete
client.files.delete("file_abc123")

Node.js

import fs from "fs";

const upload = await client.files.create({
  file: fs.createReadStream("training.jsonl"),
  purpose: "fine-tune",
});

const files = await client.files.list({ purpose: "fine-tune" });
for (const f of files.data) {
  console.log(`${f.id}: ${f.filename} (${f.bytes} bytes)`);
}

const content = await client.files.content("file_abc123");
fs.writeFileSync("downloaded.jsonl", Buffer.from(await content.arrayBuffer()));

await client.files.del("file_abc123");

Lifecycle and Quotas

  • Per-organization quota -- 100 GB total file storage on Free, 1 TB on Pro, custom on Enterprise
  • Auto-expiration -- files with purpose: vision expire after 24 hours; all other purposes are retained until you delete them
  • Idempotency -- uploads are not deduplicated; the same file uploaded twice produces two file_ids

Storage usage is visible in the dashboard under Settings > Files along with per-purpose breakdowns.

Privacy and Encryption

  • Files are encrypted at rest with AES-256-GCM
  • Encryption keys are organization-scoped and rotated quarterly
  • Pre-signed download URLs expire after 1 hour
  • BYOK provider keys never see file blobs except when explicitly referenced (e.g., during fine-tuning the JSONL is sent to the provider)

For the strictest data-handling requirements, see Zero Data Retention in Guardrails.

Troubleshooting

SymptomCauseFix
413 Payload Too LargeFile over 512 MBSplit or compress
400: invalid_jsonlOne or more JSONL lines malformedjq -c < file.jsonl to validate
quota_exceededStorage quota hitDelete unused files or upgrade plan
Download returns empty bodyFile is still processingPoll metadata until status: "processed"

See Also

  • Fine-Tuning -- consumes JSONL files via training_file
  • Plugins -- the file-parser plugin reads uploaded PDFs/DOCX
  • Images API -- alternative path for image edit sources
  • Audio API -- direct audio upload without Files API