Guides / DeepSeek Files API
DeepSeek Files API (2026): Limits, Uploads, and file_id in Practice
DeepSeek quietly shipped its first file endpoint on August 21, 2026, alongside the vision model — which makes a lot of older guides obsolete (several still claim DeepSeek's API has "no file upload route"). This guide has the verified limits, upload and reference examples in curl and Python, and when to use files instead of base64.
The DeepSeek Files API uploads an image once and returns a file_id you reference in chat.
Upload with purpose="user_data"; a file may be up to 64 MiB (10-minute upload window); storage is 25 GiB / 10,000 files per user; retention 1 hour–30 days or permanent without expires_after.
Reference files from deepseek-v4-flash-vision-exp chats via a {"type":"file","file_id":...} block — file_id images can be 64 MiB in a request versus 32 MiB inline. From the Anthropic-compatible endpoint, add the anthropic-beta: files-api-2025-04-14 header.
Limits at a glance
| Limit | Value (official docs, 2026-08-21) |
|---|---|
| Formats | JPEG, PNG, GIF, WebP — detected by file content, not extension |
| Per file | Max 64 MiB; upload must complete within 10 minutes |
| Per user | 25 GiB storage; 10,000 stored files |
| Retention | 1 hour to 30 days, or permanent (omit expires_after) |
| Purpose | Must be user_data (only supported purpose, also for list filtering) |
| In-request size | file_id image up to 64 MiB per request; inline base64/URL images capped at 32 MiB |
| API compatibility | OpenAI-compatible and Anthropic-compatible; Anthropic /messages needs the files-api beta header |
Source: official Files API guide, read 2026-08-21.
Upload once, reference forever (well, up to 30 days)
Upload a screenshot and get a file_id:
curl https://api.deepseek.com/files \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-F "purpose=user_data" \
-F "file=@dashboard.png"
Then reference it in a vision-exp chat — no base64 blob, no re-upload on subsequent turns:
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-d '{
"model": "deepseek-v4-flash-vision-exp",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Which metric regressed in this dashboard?"},
{"type": "file", "file_id": "file-api-xxxx"}
]
}]
}'
Python with the OpenAI SDK — upload, then chat:
from openai import OpenAI
client = OpenAI(api_key="YOUR_KEY", base_url="https://api.deepseek.com")
f = client.files.create(file=open("dashboard.png", "rb"), purpose="user_data")
resp = client.chat.completions.create(
model="deepseek-v4-flash-vision-exp",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Which metric regressed?"},
{"type": "file", "file_id": f.id},
],
}],
)
print(resp.choices[0].message.content)
- Inline alternative: a file block can carry
file_data(base64) instead offile_id— mutually exclusive fields;filenamemay only accompany file_data. - Anthropic-style stack: same file blocks work on /messages with the
anthropic-beta: files-api-2025-04-14header.
When to use files vs base64 vs URL
| Method | Max size | Best for |
|---|---|---|
| base64 inline | 32 MiB | One-off images generated in-process; simplest to code |
| external URL | 32 MiB, 8,192-char URL, 60s fetch | Publicly hosted images; no upload step at all |
| Files API | 64 MiB | Agent screenshot loops, repeated reference images, anything reused across turns |
FAQ
I read DeepSeek has no file endpoint — is this new?
Correct until Aug 21, 2026 — older guides describing "no /v1/files route, extract text yourself" were accurate for their time and are now outdated. The Files API shipped with the vision launch.
Can I upload PDFs or documents?
No — the Files API currently accepts image formats only (JPEG/PNG/GIF/WebP). For PDFs, render pages to images caller-side, then upload or inline them.
How long do files live?
Between 1 hour and 30 days via expires_after, or permanent if you omit it — within your 25 GiB / 10,000-file quota.
Do files work with non-vision models?
File blocks are consumed by deepseek-v4-flash-vision-exp; plain V4-Flash/V4-Pro remain text-only. Don't point file references at text models.