n4nAI

DeepSeek R1 reasoning tokens: how gateways bill for them

DeepSeek R1 reasoning tokens billing meters hidden chain-of-thought tokens generated by the model. Learn how gateways count, pass through, and charge for them.

n4n Team5 min read1,091 words

Audio narration

Coming soon — every post will get a voice note here.

DeepSeek R1 reasoning tokens billing describes how API providers and gateways meter the hidden intermediate tokens that the R1 model emits during its chain-of-thought phase. These tokens are not part of the visible answer but are counted in usage and charged at output rates. If you call deepseek-reasoner through any OpenAI-compatible endpoint, the usage object is where the money is tracked.

What Are Reasoning Tokens in DeepSeek R1

DeepSeek R1 is a reasoning-optimized model. When you call deepseek-reasoner, the model thinks before it answers. That thinking is serialized as tokens in the same vocabulary as normal text, but the API exposes it in a separate reasoning_content field rather than the content field.

Those intermediate tokens are real tokens. They consume GPU compute, they occupy the model’s context as they are generated, and they are counted by the tokenizer exactly like any other completion token. The model cannot be switched into a “no-think” mode; reasoning is intrinsic to the weights.

How DeepSeek R1 Reasoning Tokens Billing Works Upstream

DeepSeek’s native chat completion endpoint is OpenAI-compatible. You post to /chat/completions with model: "deepseek-reasoner". The response includes a usage object. In the native API, usage.completion_tokens is the sum of reasoning tokens plus visible output tokens. There is no separate line item unless you use a gateway that normalizes to OpenAI’s completion_tokens_details shape.

{
  "id": "chatcmpl-123",
  "model": "deepseek-reasoner",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Therefore sqrt(2) is irrational.",
        "reasoning_content": "Assume sqrt(2)=a/b in lowest terms..."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 1240,
    "total_tokens": 1255
  }
}

The key fact for DeepSeek R1 reasoning tokens billing: DeepSeek bills completion_tokens at the output token price. Reasoning tokens are not discounted. If your output rate is billed per million tokens, you pay for all 1240 tokens, not just the ~120 that appear in content.

How Gateways Meter and Forward Usage

A gateway proxies the request to DeepSeek (or another provider) and relays the response. It does not regenerate token counts; it trusts the provider’s usage field. A gateway that supports per-token usage metering records the exact completion_tokens and, if present, the reasoning_tokens breakdown.

n4n.ai, for example, exposes a single OpenAI-compatible endpoint covering 240+ models and forwards provider usage details verbatim, so your invoice line items map directly to what DeepSeek returned. If the upstream includes completion_tokens_details.reasoning_tokens, that field passes through; if not, the gateway may synthesize it by subtracting visible output length via the tokenizer.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.n4n.ai/v1",  # OpenAI-compatible gateway
    api_key="sk-...",
)

resp = client.chat.completions.create(
    model="deepseek/deepseek-reasoner",
    messages=[{"role": "user", "content": "Solve the traveling salesman for 5 nodes."}],
    max_tokens=4000,
)
# Gateway forwards provider usage
print(resp.usage.model_dump_json(indent=2))

Automatic fallback complicates nothing for billing: if DeepSeek is degraded and the gateway routes to a different R1 host or provider, the token counts come from whichever provider served the request. You pay for what was generated, not for the attempt.

Why This Matters to Engineers

Context Window Pressure

Reasoning tokens count against the generation limit you set with max_tokens. If you set max_tokens=1024 and the model needs 1500 reasoning tokens, the response truncates mid-thought and you get a partial or empty content. Plan for 4–8x overhead.

Cost Dominance

In practice, reasoning tokens dominate spend. A 200-token question might elicit 2000 reasoning tokens and 150 answer tokens. DeepSeek R1 reasoning tokens billing means your output cost is ~14x the visible text. Ignoring this leads to blown budgets.

Caching Behavior

Provider prompt caching (cache hits on system prompts) reduces prompt_tokens cost. Reasoning tokens are never cached—they are freshly generated each call. Gateways that forward cache-control hints help you trim input cost, but the reasoning line item remains full price.

Concrete Example: Tracing a Real Call

Below is a minimal script that calls an OpenAI-compatible endpoint, prints the breakdown, and computes relative share.

import os
from openai import OpenAI

client = OpenAI(base_url=os.environ["OPENAI_BASE_URL"], api_key=os.environ["API_KEY"])

r = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=[{"role": "user", "content": "Derive the quadratic formula."}],
    max_tokens=3000,
)

usage = r.usage
reasoning = getattr(usage.completion_tokens_details, "reasoning_tokens", None)
visible = usage.completion_tokens - (reasoning or 0)

print(f"prompt tokens: {usage.prompt_tokens}")
print(f"total completion: {usage.completion_tokens}")
print(f"reasoning: {reasoning}")
print(f"visible: {visible}")
print(f"reasoning share: {reasoning / usage.completion_tokens:.1%}" if reasoning else "no breakdown")

Sample output from a normalized gateway:

prompt tokens: 22
total completion: 1870
reasoning: 1640
visible: 230
reasoning share: 87.7%

That 87.7% is the slice DeepSeek R1 reasoning tokens billing charges you for, even though the user only reads 230 tokens.

Streaming and Incremental Metering

When streaming, you receive SSE chunks. Reasoning content arrives in delta.reasoning_content fields before delta.content. The usage object is only sent in the final chunk (or omitted by some providers until request completion). Gateways accumulate and emit a final usage. Billing is post-hoc, not per-chunk, so you cannot short-circuit a stream to save money once the model has started generating.

curl https://api.deepseek.com/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -d '{"model":"deepseek-reasoner","stream":true,"messages":[{"role":"user","content":"What is 17*23?"}]}'

In the stream, watch for the : usage event or the final data: [DONE] preceded by a usage payload. If your gateway supports it, the same completion_tokens_details appears there.

Rate Limits and Degraded Providers

If a provider returns 429 or 503, a gateway with automatic fallback routes to another region or provider that hosts the same model. The token counts are unchanged because the successful response carries its own usage. If you retry client-side without idempotency, you may double-pay for two full reasoning passes. Use gateway-provided idempotency keys or treat retries as intentional new generations.

Comparing to Other Reasoning Models

OpenAI’s o1/o3 family exposes reasoning_tokens inside completion_tokens_details natively. DeepSeek R1 is architecturally similar but typically cheaper per output token. The billing concept is identical; only the field shape differs. A gateway that normalizes both to the OpenAI shape lets you write one billing adapter. DeepSeek R1 reasoning tokens billing is uniform across hosted providers—the model dictates reasoning length, so price differences come from margins and cache efficiency, not from token accounting tricks.

Common Misconceptions

“Reasoning tokens are free because they’re hidden.” False. They are billed as output.

“I can set reasoning_effort: none to disable them.” R1 has no such parameter. The model always reasons. If you want no reasoning, use a non-reasoning model like DeepSeek-V3.

“The gateway strips them to save me money.” A compliant gateway cannot strip tokens the provider already generated; it can only choose not to log reasoning_content. The tokens were still computed and metered upstream.

“I should echo reasoning_content back in the next turn for continuity.” Doing so multiplies cost: those tokens become prompt tokens on the follow-up, and the model will generate a fresh reasoning chain anyway.

“Reasoning tokens count toward the input context limit.” They count toward the generation budget (max_tokens), not the input prompt size. But if you store full transcripts including reasoning_content, your persisted history grows fast.

Practical Guidance

  • Set max_tokens high. For R1, default to at least 4x your expected answer length.
  • Strip reasoning_content from any persisted chat history unless you have a specific debugging need.
  • Use prompt caching for static system prompts; it attacks the input side, leaving reasoning as the remaining cost lever.
  • Monitor completion_tokens_details.reasoning_tokens in your dashboards. If your gateway doesn’t expose it, subtract visible content token count via a local tokenizer.
  • When comparing providers, note that DeepSeek R1 reasoning tokens billing is uniform across hosted providers—the model architecture dictates the reasoning length, so price differences come from provider margins and cache efficiency, not from token accounting tricks.

Closing Technical Note

If you build your own abstraction, normalize on the OpenAI completion_tokens_details shape. It future-proofs your billing code when models from other vendors expose reasoning_tokens explicitly. The gateway pattern works because it decouples client code from provider quirks while preserving the exact metering that DeepSeek R1 reasoning tokens billing requires.

Tagsdeepseekdeepseek-r1reasoning-tokensbilling

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All accessing deepseek models via gateway posts →