DEV Community

APIKO
APIKO

Posted on Fully Autonomous

DeepSeek V4 Pro API: what reasoning_effort and max_tokens actually do

DeepSeek V4 Pro is a reasoning model: before it answers, it spends tokens thinking, and you pay for those tokens. I wanted to know two things before putting it in production: how much the reasoning_effort setting changes that thinking, and whether max_tokens can be used as a cost cap. So I measured it.

Disclosure: I work on APIKO, the OpenAI-compatible gateway used for these calls. Everything below is plain OpenAI SDK code and should behave the same through any gateway that passes these parameters through.

Setup

# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.apiko.app/v1", api_key=os.environ["APIKO_API_KEY"])

QUESTION = ("How many integers from 1 to 1000 are divisible by 3 or 5 but not by 15? "
            "Reply with the number and one short sentence of reasoning.")

reply = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": QUESTION}],
    reasoning_effort="low",   # low | high | max
)
print(reply.choices[0].message.content, reply.usage)
Enter fullscreen mode Exit fullscreen mode

The question is a small counting problem with one right answer (401).

Test 1: does reasoning_effort change anything?

One call per level, same question, run on 2026-10-27 through the DeepSeek V4 Pro API on APIKO:

reasoning_effort reasoning tokens completion tokens (billed) latency answer
low 266 303 7.7 s 401 ✓
high 285 327 6.2 s 401 ✓
max 330 376 6.9 s 401 ✓

On an easy question the levels barely differ: max thought about 24% more than low, all three got it right, and latency did not follow the effort level at all. One run per level is not a benchmark, so treat this as "the knob is gentle on simple tasks", not as a ranking. For extraction and classification I now default to low; the extra thinking is only worth paying for on problems where low actually gets things wrong.

Notice that completion tokens include the reasoning tokens. In every run, roughly 88% of what I paid for in output was thinking, not the answer.

Test 2: max_tokens is not a cost cap, it is an answer killer

I repeated the high run with max_tokens=64:

{"finish_reason": "length", "content": "", "completion_tokens": 64, "reasoning_tokens": 64}
Enter fullscreen mode Exit fullscreen mode

All 64 tokens went to thinking, and the visible answer came back empty. The call was cheap, but useless. In this test max_tokens capped thinking and answer together, and the thinking came first.

What I took from it:

  • Don't use max_tokens to save money on a reasoning model. Lower reasoning_effort instead.
  • If you do set max_tokens, leave room for the thinking (about 300 tokens even for this simple counting question) and check finish_reason. "length" with empty content means the model never got to answer.
  • Log usage.completion_tokens for every call; that is the number you are billed for.

Small thing that surprised me: the fixed prompt overhead

A bare "Hi" was billed as 84 prompt tokens, and each extra word added about one. So there is roughly an 80-token fixed overhead per request from the chat template. It doesn't matter for long prompts, but if you send thousands of tiny classification requests, it is most of your input cost. Batch several items into one request where you can.

Streaming with usage

If you stream, ask for usage explicitly or you won't get token counts:

stream = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": QUESTION}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print("\n", chunk.usage)
Enter fullscreen mode Exit fullscreen mode

Summary

  • Model id deepseek-v4-pro, 1M-token context, any OpenAI SDK.
  • reasoning_effort changed thinking only modestly on a simple task (266 → 330 tokens); measure it on your own prompts.
  • Most of the output bill is thinking. A small max_tokens cuts the answer, not the thinking.
  • Expect about 80 prompt tokens of overhead per request; batch tiny requests.

Request reference (tools, structured JSON output, streaming): DeepSeek docs on APIKO.

Top comments (0)