How to analyze an image with the DeepSeek Vision API

DeepSeek / Vision API

How to analyze an image with the DeepSeek Vision API

Use deepseek-flash to send an image and a question to DeepSeek’s official Chat Completions API. Put a text block and an image_url block in the same user message. The API returns text about the image, not a newly generated picture. Below is a runnable Python example, two first-response tests with the original images, and a way to check the answer and token usage.

You need a DeepSeek Platform API key and available API balance. ChinaAI is independent of DeepSeek. No image on this page is sent to an API by your visit; we ran the examples shown below.

By China AI Chat Team · Official sources reviewed and tests run September 24, 2026 · How we test

Choose the right DeepSeek image route

The word “DeepSeek” can mean the consumer assistant, an API service or a separately published model. For image input, the current official Vision guide specifies deepseek-flash. The model table maps that API name to DeepSeek-V4.1-Flash and marks deepseek-v4-pro as having no Vision support. An older Vision alias may still be accepted, but it routes to the current Flash model; use deepseek-flash in new code.

What you needUse this routeBoundary
Ask a developer API about a PNG, photo, chart or screenshotOfficial Vision API, model deepseek-flashInput image, text answer. This page shows the request and a checkable result.
Upload a PDF in the consumer assistantOur DeepSeek PDF guideA different product and workflow; API Vision support does not establish the web app’s current upload controls.
Make a new image from wordsOur DeepSeek image-generation guideVision image input is not image output.

For a small image already on your computer, start with an inline base64 data URL as below. A public HTTPS image URL avoids embedding the bytes in your request but exposes the image at that URL to retrieval by the service. The Files API is suited to reusing an uploaded image by file_id; review its storage and expiry controls before sending material you must delete. All three are documented methods, but the code below tests the inline method only.

Send one image with Python

This example uses Python’s standard library, the official /chat/completions endpoint and our fictional chart image. Save the PNG locally as support-tickets-chart.png. Set DEEPSEEK_API_KEY in your own environment or secret manager; never put the key in a web page, browser JavaScript, public repository or the command-line example itself. Our general DeepSeek API guide covers account setup and the first text request.

import base64, json, os
from pathlib import Path
from urllib.request import Request, urlopen

image = Path("support-tickets-chart.png")
key = os.environ["DEEPSEEK_API_KEY"]
encoded = base64.b64encode(image.read_bytes()).decode("ascii")
prompt = (
    "Read the chart. Which region has the most September support "
    "tickets, and how many more tickets does it have than South? "
    "Give the two numbers you used. Do not infer a trend."
)
body = {
    "model": "deepseek-flash",
    "messages": [{"role": "user", "content": [
        {"type": "text", "text": prompt},
        {"type": "image_url", "image_url": {
            "url": "data:image/png;base64," + encoded,
            "detail": "original"
        }}
    ]}],
    "thinking": {"type": "disabled"},
    "max_tokens": 512,
    "stream": False
}
request = Request(
    "https://api.deepseek.com/chat/completions",
    data=json.dumps(body).encode("utf-8"),
    method="POST",
    headers={"Content-Type": "application/json",
             "Authorization": "Bearer " + key}
)
with urlopen(request, timeout=90) as response:
    result = json.load(response)
choice = result["choices"][0]
print("Answer:", choice["message"].get("content"))
print("Finish reason:", choice.get("finish_reason"))
print("Returned model:", result.get("model"))
print("Usage:", result.get("usage"))

We used detail: original because the small chart labels matter. The official guide says low downsamples to 512 × 512, while auto currently behaves like original; check those semantics again if you change the request. Thinking is explicitly disabled here to keep the small test bounded; DeepSeek’s pricing page says thinking is otherwise the default for Flash. Always inspect finish_reason: stop means this response ended normally, while length means the output limit cut it short.

To try another image, replace the image path, MIME prefix and prompt. The full downloadable example and test records (ZIP) include both input images, exact prompts, first responses and a standalone Python file. Run code on your own computer or backend, not in public client-side JavaScript.

What the API read in our two images

Before calling the API, we fixed each fictional image, exact question and answer checks. We used the official endpoint on September 24, 2026, with deepseek-flash, inline PNG, detail: original, non-thinking mode, max_tokens: 512 and no streaming. Each image had one successful provider request and we kept its first text. Both successful calls returned HTTP 200, model deepseek-flash and finish_reason: stop.

Test 1: compare three chart values

Fictional September support-ticket bar chart: North 24, South 18 and West 31.
Our original test chart. The correct result is West 31 versus South 18, a difference of 13.

Exact question: “Read the chart. Which region has the most September support tickets, and how many more tickets does it have than South? Give the two numbers you used. Do not infer a trend.”

West has the most September support tickets with 31. It has 13 more tickets than South (31 – 18 = 13).

The first response identified the largest bar, both numbers and their difference, without inventing a trend. It used 547 cache-miss prompt tokens, zero cache-hit tokens and 28 output tokens.

Test 2: read a screenshot without inventing publication

Fictional service-notice screenshot marked Draft and not published, showing maintenance Thursday 16:00–17:30 UTC.
Our original fictional screenshot. Its draft status matters as much as the time text.

Exact question: “Read this screenshot. What is the publication status, and what exact maintenance window is shown? State whether the screenshot proves the notice was published.”

The publication status is Draft — not published (also shown by the DRAFT badge). The maintenance window is Thursday, 16:00–17:30 UTC. No — the screenshot shows the notice is still a draft, so it does not prove the notice was published.

The first response preserved the status, window and publication distinction. It used 538 cache-miss prompt tokens, zero cache-hit tokens and 55 output tokens. These two clear, synthetic examples show what happened in these calls only; they do not measure OCR accuracy on blurry photos, reliability across many requests or performance with private production documents. Verify important extracted numbers, dates and status against the source image before acting on them.

Connection issue during the chart test

A local network block stopped an earlier chart attempt before any HTTP response; after network access was enabled, the first provider response was saved.

How to read usage and estimate cost

Images become input tokens. DeepSeek’s Vision guide describes its resizing rules and a current upper bound of 1,024 image tokens per image; the actual request also includes your text and message framing. Use the usage returned by the API, not the PNG file size, for a rate-based estimate. The token-usage guide explains the counters.

For our chart, the returned counters were 547 cache-miss input and 28 output tokens. At the official off-peak Flash rates reviewed September 24, 2026, the arithmetic is (547 × $0.15 + 28 × $0.60) / 1,000,000 = $0.00009885. The notice’s returned 538 input and 55 output tokens give an estimated $0.00011370 on the same basis. Both have zero cache-hit tokens. These tiny amounts are estimates from response counters and published rates, not a checked invoice or exact provider deduction. Rates, cache status and peak windows can change; see our DeepSeek pricing guide for the current table and calculator before budgeting a larger workflow.

Limits, errors and a safer production check

  • 400 or unsupported input: Use deepseek-flash, put the image in a user message, and make content an array containing text and image_url blocks. Chat Completions and the Responses API use different image-block shapes; do not copy one into the other.
  • 401 authentication or 402 insufficient balance: A 401 points to an invalid API key; check your private key and endpoint. A 402 means the platform balance is insufficient. See DeepSeek’s official error codes. Never paste a key into a public troubleshooting post.
  • Oversized, wrong-format or unreachable image: The supported formats are JPEG, PNG, GIF and WebP. The current Vision limits include a 48 MiB request-body cap and 32 MiB maximum for one inline or external image. A file_id image has a different 64 MiB cap. External URLs must be accessible to DeepSeek and download within the documented time limit. Our two small PNGs were far below these caps.
  • Incomplete or doubtful answer: Check HTTP status, finish_reason, returned model and usage. Ask for exact values or quotes, compare them with the image, and route uncertain or consequential answers to human review. A normal finish does not prove factual correctness.

Inline image bytes go to the API in each request. A public URL can expose the asset to anyone with that URL. An uploaded Files API asset has separate storage behavior and deletion controls in the official Files API documentation. Choose a method that fits your data-handling requirements; we tested only fictional non-sensitive images.

Common questions and next steps

Does DeepSeek Vision generate a new image?

No: this documented deepseek-flash path accepts an image and returns text. For DeepSeek’s separate image-generation research route and our consumer-chat observation, read the image-generation guide.

Can I send a web image instead of base64?

Yes. The official guide accepts an accessible HTTP(S) URL inside image_url.url. Use a Files API file_id for repeated reuse or larger uploads. Our actual tests used inline PNG only.

Is this the same as DeepSeek’s web chat?

No. An API feature, key and billable token response do not establish a specific upload control, model or plan in the consumer assistant. Start at our DeepSeek overview to choose the product route; use the models guide for hosted-name and release distinctions.

Sources: DeepSeek Vision guide, Models & Pricing, Token Usage and Files API, all reviewed September 24, 2026. Our evidence package contains the two input files, exact prompts, first responses and reproducible code. We will update this guide when the serving model, image format, price, limits or request shape changes. Send a correction with the source and date you checked.