DeepSeek-v4-flash-vision-exp
DeepSeek-v4-flash-vision-exp
The deepseek-v4-flash-vision-exp model is a multimodal powerhouse capable of processing both textual and visual data. This allows users to perform tasks such as image captioning, OCR (optical character recognition) from screenshots, and complex chart analysis.
Note: The system determines the image format by analyzing the actual file content; it
does not rely on the file extension or the MIME type.
🖼️ Methods for Sending Images
You can provide visual input using three distinct methods. All three follow the OpenAI-compatible Chat Completions standard, utilizing an array of content blocks rather than a simple string. These methods are also compatible with the Responses API via input_image parts.
API Base URL: https://api.deepseek.com
1. Base64-Encoded Images (Inline)
You can embed an image directly into your JSON request by encoding it as a data: URL.
- Constraint: The encoded string contributes to the total request body limit of 48 MiB.
Python Example:
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_DEEPSEEK_API_KEY", base_url="https://api.deepseek.com")
with open("image.jpg", "rb") as f:
b64 = base64.b64encode(f.read()).decode('utf-8')
response = client.chat.completions.create(
model="deepseek-v4-flash-vision-exp",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}},
],
}
],
)
print(response.choices[0].message.content)
cURL Example:
curl https://api.deepseek.com/chat/completions \
-H Content-Type: application/json \
-H Authorization: Bearer YOUR_DEEPSEEK_API_KEY \
-d '{
"model": "deepseek-v4-flash-vision-exp",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,BASE64_DATA"}}
]
}
]
}'
2. External Image URLs
Provide a publicly accessible link, and the model will fetch the image automatically.
- URL Length: Max 8,192 characters.
- File Size: Max 32 MiB.
- Timeout: Download must finish within 60 seconds.
client.chat.completions.create(
model="deepseek-v4-flash-vision-exp",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image."},
{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}},
],
}
],
)
3. Files API Reference
Upload an image once via the Files API and reference its file_id (e.g., file-api-xxxxxxxxxxxxxxxx). This is the most efficient method for repeated use of the same asset or for very large files.
- Advantage: Images can be up to 64 MiB and bypass the 32 MiB check applied to URLs/Base64.
client.chat.completions.create(
model="deepseek-v4-flash-vision-exp",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "file", "file_id": "file-api-xxxxxxxxxxxxxxxx"},
],
}
],
)
Alternatively, you can use a file block with file_data (base64) and a filename instead of a file_id.
🛠️ Configuration & Optimization
Detail Level
For image_url inputs, you can specify the detail parameter:
| Value | Behavior |
|---|---|
low | Image is downscaled to pixels before processing. |
original | The image is processed in its original resolution. |
Example: {"type": "image_url", "image_url": {"url": "...", "detail": "low"}}
When to utilize the Files API?
- Your request body exceeds the 48 MiB limit.
- Your image file is larger than 32 MiB.
- You are using the same image across multiple different requests.
🪙 Token Usage & Billing
Images are converted into tokens based on their dimensions. These are billed alongside your text tokens.
The Resizing Logic:
- Upscaling: Images smaller than roughly pixels are scaled up (maintaining aspect ratio).
- Downscaling: Larger images are scaled down (maintaining aspect ratio) to a total pixel count roughly equivalent to an image.
Key Token Facts:
- Upper Bound: There is a maximum of 384 tokens per image.
- Consistency: A image and a image will cost the same amount of tokens.
- Multi-Image: Each image is calculated independently; there is no bulk discount or different formula for multiple images.
📏 System Limits
| Limit | Value |
|---|---|
| Supported Formats | JPEG, PNG, GIF, WebP |
| External URL Max Length | 8,192 characters |
| Request Body Max Size | 48 MiB |
| Max Image Size (Base64/URL) | 32 MiB |
| Max Image Size (Files API) | 64 MiB |
| Max Images per Request | 600 |
Total Image Size (no file_id) | 64 MiB |
Total Image Size (with file_id) | 200 MiB |
| Max Image Dimension | 8,192 px per side (drops to 4,096 px if images) |
⚠️ Restrictions
- Message Role: Images are only permitted in
usermessages. Including them insystemorassistantmessages will trigger a400error. - Model Compatibility: Only
deepseek-v4-flash-vision-expsupports images. Other models will return a400error stating "This model does not support image". - Reserved Tokens: Any user text containing the internal reserved image placeholder token will be rejected with a
400error.
🔌 Anthropic API Compatibility
Beyond the OpenAI-style endpoint, you can also transmit images using the Anthropic-compatible /messages endpoint by setting your base_url to https://api.deepseek.com/anthrop.