File management API
Upload files for document analysis or batch processing using the OpenAI-compatible Files API.
Use the OpenAI SDK (Python/Node.js) or HTTP to upload, query, list, and delete files.
Prerequisites:
File IDs work with:
You can store up to 10,000 files and 100 GB total. Files never expire.
Set
Set
File operations (upload, storage, query, delete) are free. You are charged only for model inference tokens (input + output).
Rate limits: upload (3 QPS), query/list/delete (10 QPS combined).
Processing typically completes in seconds. If it persists:
No. File IDs are scoped to the Qwen Cloud account that created them.
Yes. Files persist until you delete them.
Usage
Use the OpenAI SDK (Python/Node.js) or HTTP to upload, query, list, and delete files.
Prerequisites:
- An API key: Create an API key and Export the API key as environment variable.
- To use the OpenAI SDK, install the OpenAI SDK.
Model availability
File IDs work with:
- Batch processing: Batch file upload.
Endpoints
| Endpoint | Description |
|---|---|
| Upload file | Upload a file for document analysis or batch processing |
| Retrieve file | Retrieve file details by ID |
| List files | List all files in your account |
| Delete file | Delete a file by ID |
Getting started
Upload a file
You can store up to 10,000 files and 100 GB total. Files never expire.
For document analysis
Set purpose to file-extract. Supported formats: text files (TXT, DOCX, PDF, XLSX, EPUB, MOBI, MD, CSV, JSON) and images (BMP, PNG, JPG/JPEG, GIF, scanned PDFs). Maximum file size: 150 MB.
Request examples
- Python
- Node.js
- cURL
Sample response
For batch processing
Set purpose to batch. Upload a JSONL file conforming to Batch file requirements. Maximum file size: 500 MB.
For batch calls, see OpenAI compatible - Batch.
Request examples
- Python
- Node.js
- cURL
Sample response
Billing
File operations (upload, storage, query, delete) are free. You are charged only for model inference tokens (input + output).
Rate limits
Rate limits: upload (3 QPS), query/list/delete (10 QPS combined).
Going live
- Periodic cleanup: Delete unused files to stay under the 10,000-file limit.
-
Status verification: Confirm
status="processed"before using uploaded files. - Rate limit awareness: Upload (3 QPS), query/list/delete (10 QPS). Implement retry with exponential backoff.
- Error handling: Handle network timeouts, API errors (invalid format, size exceeded), and file limit errors. See Error codes.
FAQ
1. What if file status stays "processing" after upload?
Processing typically completes in seconds. If it persists:
- Verify the file format is supported.
- Verify the file size is within limits (file-extract: 150 MB, batch: 500 MB).
- Poll status with the
retrieveAPI.
2. Can file IDs be shared across accounts?
No. File IDs are scoped to the Qwen Cloud account that created them.
3. Are uploaded files stored permanently?
Yes. Files persist until you delete them.
4. Why did file upload fail?
- Invalid or missing API key (
$DASHSCOPE_API_KEYnot set). - Unsupported file format.
- File size exceeds limit (file-extract: 150 MB, batch: 500 MB).
- Storage limit reached (10,000 files or 100 GB total).
- Rate limit exceeded (3 QPS for upload).
5. When should I use file-extract vs batch?
file-extract: Document analysis and data extraction.batch: Batch inference tasks (requires JSONL format).