Updated 2026-11-20

DeepSeek V4.1 Flash Guide: Model ID, API and File Input

Use deepseek-flash to call DeepSeek-V4.1-Flash-1017 on DeepSeek's official API. A text prompt goes directly in a chat message, a screenshot uses an image part, and a PDF uses a file ID returned after parsing. Choose the walkthrough that matches what you have in hand.

Download the PDF and prepare your shell

The Northline Dispatch sample is a fictional operations report. It contains a text table titled Intake register and a chart titled Dispatch chart. The parcel counts on the chart are printed inside the image.

Run the three code blocks in order in the same Bash session. You'll need curl, Python 3 and a key for a funded official DeepSeek API account. The commands use Python's standard library. The key prompt hides what you type.

bash
mkdir -p flash-pdf
cd flash-pdf
curl --fail --location --silent --show-error \
  https://deepseekv4pro.com/guides/deepseek-v4-1-flash/dispatch-report.pdf \
  --output dispatch-report.pdf

read -r -s -p "DeepSeek API key: " DEEPSEEK_API_KEY
export DEEPSEEK_API_KEY
printf '\n'

Upload the report with its chart

This question needs a number drawn inside an image. Choose rich_layout_recognition so the parser can include detected figures alongside the text. For a document where the answer appears in ordinary paragraphs, text_recognition is sufficient and omits figures.

Send the purpose field before the file field. DeepSeek returns an ID after parsing succeeds. The commands save the upload receipt and read its ID into FLASH_FILE_ID for the next step. This upload requests a one-hour lifetime.

bash
curl --fail --silent --show-error --max-time 270 \
  https://api.deepseek.com/files \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -F 'purpose=rich_layout_recognition' \
  -F 'expires_after[anchor]=created_at' \
  -F 'expires_after[seconds]=3600' \
  -F 'file=@dispatch-report.pdf;type=application/pdf' \
  --output upload.json &&
  FLASH_FILE_ID=$(python3 -c 'import json; print(json.load(open("upload.json"))["id"])') &&
  export FLASH_FILE_ID

Ask Flash a question about the chart

After the upload succeeds, send one Chat Completions request. Its user message has two parts: a file block with the ID from the previous step and a text block with the question. The response prints the answer and token usage in your terminal.

Open the page Flash cites and look at the Cedar bar in the Dispatch chart. Check the number beside that bar and the unit in the chart header. If the model cannot read the value, figure detection may have missed the chart.

bash
python3 - <<'PY'
import json
import os
from urllib.request import Request, urlopen

payload = {
    "model": "deepseek-flash",
    "thinking": {"type": "disabled"},
    "messages": [{
        "role": "user",
        "content": [
            {"type": "file", "file_id": os.environ["FLASH_FILE_ID"]},
            {"type": "text", "text": (
                "According to the chart, how many parcels did Cedar complete? "
                "Give the unit and printed page number. If the value is unreadable, say so."
            )},
        ],
    }],
}
req = Request(
    "https://api.deepseek.com/chat/completions",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": "Bearer " + os.environ["DEEPSEEK_API_KEY"],
        "Content-Type": "application/json",
    },
)
with urlopen(req, timeout=120) as response:
    result = json.load(response)
print(result["choices"][0]["message"]["content"])
print("Token usage:", result["usage"])
PY

Calculate the file fee and the chat cost

DeepSeek lists file parsing at $0.225 per 1,000 pages as of November 19, 2026. A successful upload of this three-page PDF therefore costs 3 × $0.225 / 1,000 = $0.000675. While the file ID is valid, you can reference it again without a second parsing charge.

Chat is billed separately. In the returned usage, find the cache-hit input tokens, cache-miss input tokens and completion tokens. Multiply each count by its applicable USD rate per million tokens, add the results and divide by 1,000,000. Parsed text and any extracted figures contribute to input usage.

FAQ

Can I pass the PDF URL directly to chat?

The document file block requires the ID returned by the Files API. Download the source PDF and upload its bytes before referencing it.

Why did the file upload return HTTP 400?

A PDF requires a document-parsing purpose. Check that purpose comes before file in the multipart form, that the downloaded file opens as a PDF and that it is not password-protected.

Can I ask a follow-up after the first answer?

Yes. While the file ID is valid, change the question in the chat request and keep the same file block. Each chat incurs its own token usage. After the one-hour expiry used here, upload the document again for a new ID.

Related model comparisons

Continue from this guide into structured DeepSeek-first comparison pages with model tables, routing advice, and pricing context.