Skip to main content
File

Upload file

Upload a file for document analysis or batch processing. You can store up to 10,000 files and 100 GB total. Files never expire.

POST
/files
Python
import os
from pathlib import Path
from openai import OpenAI

client = OpenAI(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)

# Upload for document analysis
file_object = client.files.create(
  file=Path("test.txt"),
  purpose="file-extract"
)
print(file_object.model_dump_json())
{
  "id": "file-fe-xxx",
  "bytes": 2055,
  "created_at": 1729065448,
  "filename": "test.txt",
  "object": "file",
  "purpose": "file-extract",
  "status": "processed",
  "status_details": null
}

Authorizations

string
header
required

Qwen Cloud API Key. Create one in the console.

Body

multipart/form-data
file
required

The file to upload.

enum<string>
required

The intended use of the file.

  • file-extract: Document analysis. Max 150 MB. Supported formats: TXT, DOCX, PDF, XLSX, EPUB, MOBI, MD, CSV, JSON, BMP, PNG, JPG/JPEG, GIF, scanned PDFs.
  • batch: Batch processing. Max 500 MB. JSONL format (Batch file requirements).
file-extract,batch

Response

200-application/json
string

Unique file identifier.

file-fe-xxx
integer

File size in bytes.

2055
integer

Unix timestamp (seconds) when the file was created.

1729065448
string

The uploaded filename.

test.txt
enum<string>

Always file.

file
string

File purpose. Valid values: batch, file-extract, batch_output.

file-extract
string

Current file status.

processed
string | null

Additional status details. null when no details available.