DeepSeek-R1 Architecture & Reasoning API: How Open Reasoning Models Work
DeepSeek-R1 is an open-weights reasoning model that uses large-scale Reinforcement Learning (RL) without supervised fine-tuning warm-up (R1-Zero) followed by cold-start multi-stage training to produce transparent chain-of-thought thinking tokens at 90% lower API inference costs than proprietary models.
Overview #
DeepSeek-R1 is an open-weights reasoning model that uses large-scale Reinforcement Learning (RL) without supervised fine-tuning warm-up (R1-Zero) followed by cold-start multi-stage training to produce transparent chain-of-thought thinking tokens at 90% lower API inference costs than proprietary models.
The Pure RL Paradigm (DeepSeek-R1-Zero to R1) #
Traditional LLMs rely on human-curated Supervised Fine-Tuning (SFT) before RLHF. DeepSeek demonstrated that applying Group Relative Policy Optimization (GRPO) directly to base models allows reasoning behaviors to emerge naturally. The model develops self-reflection, alternative search strategies, and error-correction capabilities autonomously. To avoid language mixing and formatting degradations observed in R1-Zero, the production DeepSeek-R1 adds cold-start curated reasoning data prior to secondary RL.
Reasoning Tokens & Thinking Token Accounting #
DeepSeek-R1 emits explicit thinking phases inside XML tags before generating the final response choice. In OpenAI-compatible APIs, these tokens can either be streamed directly to client frontends inside the reasoning_content delta field or collapsed into token billing counters. Applications using DeepSeek-R1 must account for thinking tokens within their context budget, as complex mathematical or architectural proofs can consume 4,000 to 16,000 thinking tokens before outputting the final solution.
Distilled Small Models (R1-Qwen and R1-Llama) #
In addition to the 671B MoE checkpoint, DeepSeek open-sourced distilled versions based on Qwen-2.5 and Llama-3 (1.5B, 7B, 8B, 14B, 32B, and 70B parameters). These distilled checkpoints retain strong reasoning benchmarks (such as MATH-500 and AIME) while running on single enterprise GPUs or local edge devices with sub-100ms time-to-first-token.
Code Example: Consuming DeepSeek-R1 with Streaming Thinking Tokens #
from openai import OpenAI
client = OpenAI(
base_url="https://api.apihundred.com/v1",
api_key="your_api100_key"
)
# DeepSeek-R1 streams reasoning_content alongside standard content
stream = client.chat.completions.create(
model="deepseek-r1",
messages=[
{"role": "user", "content": "Prove that there are infinitely many primes p such that p+2 is not prime."}
],
stream=True
)
for chunk in stream:
delta = chunk.choices[0].delta
# Check for thinking token stream
if hasattr(delta, "reasoning_content") and delta.reasoning_content:
print(f"[Thinking]: {delta.reasoning_content}", end="", flush=True)
elif delta.content:
print(delta.content, end="", flush=True)
Frequently Asked Questions #
Q: How does DeepSeek-R1 differ from OpenAI o1?
DeepSeek-R1 is an open-weights model with transparent chain-of-thought tokens accessible via standard API fields (reasoning_content), whereas OpenAI o1 is closed-source and suppresses raw thinking tokens for commercial privacy.
Q: Do thinking tokens count against API rate limits and token billing?
Yes. Reasoning tokens consume GPU compute during inference and are billed as input or completion tokens according to the gateway pricing matrix.
Q: What is GRPO in DeepSeek-R1?
Group Relative Policy Optimization (GRPO) evaluates outputs against a group baseline rather than requiring an explicit critic neural network, drastically reducing GPU VRAM training requirements.
Build with API100
Access 100+ AI models through one lightning-fast OpenAI-compatible API with sub-50ms routing overhead and zero markup on cached tokens.

