DeepSeek-v4-flash-vision-exp

dares25731 pts0 comments

Vision | DeepSeek API Docs

Skip to main content

On this page<br>Vision

The deepseek-v4-flash-vision-exp model accepts images alongside text, so you can ask the model to describe pictures, read text from screenshots, analyze charts, and more.

Supported image formats: JPEG, PNG, GIF, and WebP . The format is detected from the actual file content, not from the file name or the declared MIME type.

Sending Images​

There are three ways to provide an image to the model. All of them use the standard OpenAI-compatible Chat Completions format, where content is an array of blocks instead of a plain string. The same three methods are also available in the Responses API, where images are carried in input_image content parts.

The base_url for the examples below is https://api.deepseek.com.

1. Base64-encoded image (inline)​

Encode the image and embed it directly in the request as a data: URL. This is the simplest option for local files. The encoded data counts toward the 48 MiB request body limit (see Limits).

import base64<br>from openai import OpenAI

client = OpenAI(api_key="", base_url="https://api.deepseek.com")

with open("image.jpg", "rb") as f:<br>b64 = base64.b64encode(f.read()).decode("utf-8")

response = client.chat.completions.create(<br>model="deepseek-v4-flash-vision-exp",<br>messages=[<br>"role": "user",<br>"content": [<br>{"type": "text", "text": "What is in this image?"},<br>"type": "image_url",<br>"image_url": {"url": f"data:image/jpeg;base64,{b64}"},<br>},<br>],<br>],<br>print(response.choices[0].message.content)

curl https://api.deepseek.com/chat/completions \<br>-H "Content-Type: application/json" \<br>-H "Authorization: Bearer " \<br>-d '{<br>"model": "deepseek-v4-flash-vision-exp",<br>"messages": [<br>"role": "user",<br>"content": [<br>{"type": "text", "text": "What is in this image?"},<br>{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,"}}<br>}'

2. External image URL​

Pass a publicly accessible http(s) link and the model downloads the image for you. The URL must be at most 8192 characters , the image file may be at most 32 MiB , and the download must complete within 60 seconds . If your link is longer, use a base64 data URL or the Files API instead.

response = client.chat.completions.create(<br>model="deepseek-v4-flash-vision-exp",<br>messages=[<br>"role": "user",<br>"content": [<br>{"type": "text", "text": "Describe this image."},<br>"type": "image_url",<br>"image_url": {"url": "https://example.com/image.jpg"},<br>},<br>],<br>],<br>print(response.choices[0].message.content)

3. Reference a file uploaded via the Files API​

Upload an image once with the Files API, then reference its file_id in your requests. This is the best option when you reuse the same image across multiple requests, or when the image pushes the request body over the 48 MiB inline limit. Unlike inline images, images referenced via Files API file_id may be up to 64 MiB and are not subject to the 32 MiB per-image check.

Use a file content block with the returned file_id (which has the form file-api-...):

response = client.chat.completions.create(<br>model="deepseek-v4-flash-vision-exp",<br>messages=[<br>"role": "user",<br>"content": [<br>{"type": "text", "text": "What is in this image?"},<br>{"type": "file", "file_id": "file-api-xxxxxxxxxxxxxxxx"},<br>],<br>],<br>print(response.choices[0].message.content)

Alternatively, a file block can carry the image inline as base64 via file_data instead of file_id (the two are mutually exclusive):

"type": "file",<br>"file_data": "data:image/jpeg;base64,",<br>"filename": "image.jpg"

Detail Level​

For image_url inputs you can optionally set a detail field to control how the image is processed:

ValueBehaviorlowThe image is downscaled to 512×512 before inference. Faster and cheaper when fine visual detail is not important.highKeeps the original image. (Provided for compatibility; equivalent to original.)originalKeeps the original image.autoAutomatic selection. Currently equivalent to original.<br>"type": "image_url",<br>"image_url": {"url": "https://example.com/image.jpg", "detail": "low"}

When to Use the Files API​

Inline images (base64 or file_data) count toward the request body size limit of 48 MiB . Consider the Files API when:

A single request would exceed the body size limit.

The image is larger than 32 MiB, which is only possible through the Files API.

You reference the same image in multiple requests and want to avoid re-uploading it each time.

Token Usage​

Images are converted into tokens based on their dimensions, and these tokens are billed together with your text tokens.

Before inference, every image is automatically resized:

Images with a total pixel count below roughly 384×384 are scaled up while preserving their aspect ratio.

Larger images are scaled down while preserving their aspect ratio, so that the total pixel count after resizing is roughly that of an 800×800 image.

As a result, there is an upper bound of 384 tokens per image: for example, a 2000×2000 image and a 5000×5000 image consume the same number of tokens after resizing. When a request contains multiple...

image content type text deepseek file

Related Articles