Overview
V3 introduces persistent file storage that allows you to:- Upload files once and reference them across multiple requests
- Reduce upload overhead and latency
- Manage file lifecycle with automatic expiration
File Intent (purpose)
Thepurpose field is optional. When provided, it tags the file with its intended use making it easy to filter your uploaded files by intent when retrieving them later.
| Purpose | Use case |
|---|---|
assistants | Attach the file to an LLM chat completion (PDF, documents) |
ocr | Extract text from documents or images |
financial_parser | Parse invoices, receipts, and financial documents |
identity_parser | Extract data from IDs, passports, and similar documents |
resume_parser | Extract structured data from CVs and resumes |
speech | Transcribe audio files |
Upload a File
Response
Use Uploaded File
Once uploaded, reference the file by itsfile_id in an LLM chat completion:
File Size Limits
- Default maximum: 100 MB per file
- Actual limits may vary by feature and provider
- Check provider-specific documentation for exact limits
File Expiration
Files are automatically deleted after a retention period:- Default retention: 7 days
- Files expire at the timestamp shown in
expires_at - Expired files cannot be recovered
- Upload new files as needed
Upload Multiple Files
Error Handling
Best Practices
1. Reuse Files
Upload once, use in multiple requests:2. Track File Metadata
Keep track of uploaded files:3. Handle Large Files
For large files, show upload progress:Common Errors
413 Payload Too Large
File exceeds size limit. Compress or split the file.415 Unsupported Media Type
File format not supported. Check supported formats above.422 Validation Error
Invalid request format. Ensure file field is properly set.Next Steps
Chat Completions
Use uploaded files in LLM conversations
Streaming
Stream responses when processing documents