Files and storage
The Storage API is a per-key file store: upload a file, get its id, download it whenever you need it. Two storage policies:
| Policy | Lifetime | Quota |
|---|---|---|
temp |
7 days, then automatic deletion | none |
permanent |
forever | 1 GB across all permanent files |
The policy is set at upload time with the policy parameter (default temp); a temporary file can be made permanent later with keep (see below). Every file carries expires_at in the response — the moment after which a temporary file disappears.
Upload
Section titled “Upload”from openai import OpenAI # same SDK: /v1/files is shape-compatible
client = OpenAI(base_url="https://api.mixen.ai/v1", api_key=API_KEY)with open("report.pdf", "rb") as f: stored = client.files.create(file=f, purpose="storage")print(stored.id, stored.filename)curl https://api.mixen.ai/v1/files \ -H "Authorization: Bearer $MIXEN_API_KEY" \ -F "file=@report.pdf" \ -F "policy=permanent"{ "id": "552", "object": "file", "filename": "report.pdf", "mime": "application/pdf", "size_bytes": 48213, "policy": "permanent", "expires_at": null, "created_at": 1793731200}Limits: files up to 25 MB; empty files are rejected. A permanent upload past the quota returns 400 storage_quota_exceeded with quota_bytes and free_bytes in the error body — free space by deleting or upload as temp.
Download and metadata
Section titled “Download and metadata”Bytes at GET /v1/files/{id}/content (HTTP Range is supported — video files can be scrubbed), metadata at GET /v1/files/{id}:
curl -H "Authorization: Bearer $MIXEN_API_KEY" \ https://api.mixen.ai/v1/files/552/content -o report.pdfA stored file is a convenient source for generation: fetch content and pass the bytes as file_data in file input or as an image data: URL in vision requests.
Listing and stats
Section titled “Listing and stats”GET /v1/files — your files, newest first, cursor pagination like history: pass the response’s next_cursor as cursor.
GET /v1/files/stats — what is stored:
{ "temp": {"files": 3, "bytes": 1048576}, "permanent": {"files": 2, "bytes": 5242880}, "quota_bytes": 1073741824, "free_bytes": 1068496896}Keep — store forever
Section titled “Keep — store forever”PATCH /v1/files/{id}/keep switches a temporary file to permanent storage: expires_at is cleared and the file is no longer deleted automatically. Calling it twice is harmless. If the 1 GB quota is already spent — the same storage_quota_exceeded error as on upload.
curl -X PATCH -H "Authorization: Bearer $MIXEN_API_KEY" \ https://api.mixen.ai/v1/files/553/keepDeleting
Section titled “Deleting”DELETE /v1/files/{id} removes the file and its metadata permanently — both temp and permanent.
curl -X DELETE -H "Authorization: Bearer $MIXEN_API_KEY" \ https://api.mixen.ai/v1/files/552{"id": "552", "object": "file", "deleted": true}Expiry and deletion are final: the file is not recoverable and its id stops resolving (404). Downloading does not extend a temporary file’s lifetime — only keep does.