APIMaster.ai

DeepSeek R1 API Guide — Reasoning Model Access | APIMaster.ai

How to use DeepSeek reasoning models with Python. Covers DeepSeek R1 search intent, V4 thinking mode, prompt strategies, and APIMaster.ai access.

DeepSeek R1 API Guide

DeepSeek R1 is a common search term for DeepSeek's reasoning capability. For current API integrations, use DeepSeek V4 Pro thinking mode; the legacy deepseek-reasoner compatibility entry is scheduled for retirement after July 24, 2026.

What Makes DeepSeek R1 Different

Unlike standard chat models, R1:

  1. Reasons before answering: thinking mode returns reasoning in a separate reasoning_content field
  2. Excels at formal reasoning: math proofs, code verification, logic puzzles
  3. Open weights: the base model is open-source (weights available on HuggingFace)
  4. Competitive performance: matches o1 on many benchmarks at much lower cost

DeepSeek R1 API Quickstart

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_APIMASTER_KEY",
    base_url="https://apimaster.ai/v1",
)

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {
            "role": "user",
            "content": "Prove that the square root of 2 is irrational.",
        }
    ],
    max_tokens=2048,  # R1 needs more tokens for reasoning
)

message = response.choices[0].message
print(getattr(message, "reasoning_content", ""))
print(message.content)

Understanding Reasoning Output

DeepSeek V4 thinking mode usually returns reasoning separately from the final answer:

message = response.choices[0].message
reasoning = getattr(message, "reasoning_content", "")
answer = message.content
print(answer)

Prompt Strategies for DeepSeek R1

Math and Proofs

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {
            "role": "user",
            "content": """Solve step by step:
Find all integer solutions to: x² - 5y² = 1

Show your reasoning."""
        }
    ],
    max_tokens=3000,
)

Code Verification

code = """
def merge_sort(arr):
    if len(arr) <= 1:
        return arr
    mid = len(arr) // 2
    left = merge_sort(arr[:mid])
    right = merge_sort(arr[mid:])
    return merge(left, right)
"""

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {
            "role": "user",
            "content": f"Verify this merge sort implementation is correct:\n\n```python\n{code}\n```\n\nFind any bugs or edge cases."
        }
    ],
)

Multi-Step Logic

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {
            "role": "user",
            "content": """You have 3 boxes. One contains only apples, one only oranges, one both. All boxes are mislabeled. You can draw one fruit from one box. Which box do you pick and why?"""
        }
    ],
)

DeepSeek R1 vs Other Reasoning Models

Model Strengths Price Range Context
deepseek-v4-pro Math, science, complex reasoning Live pricing 1M
o3 (OpenAI) Broad reasoning High 200K
o4-mini Fast reasoning Medium 128K
claude-opus-4-8 Complex analysis High 1M

DeepSeek reasoning models are often cost-effective, but pricing varies by model tier, cache hit rate, and output length.

Handling Long Reasoning Outputs

R1 can produce very long outputs—set max_tokens high for complex tasks:

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Solve this calculus problem: ..."}],
    max_tokens=4096,  # High limit for complex reasoning
)

# Check if output was truncated
if response.choices[0].finish_reason == "length":
    print("Warning: Output truncated—increase max_tokens")

Streaming R1 Responses

For better UX on long reasoning tasks:

with client.chat.completions.stream(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Explain Gödel's incompleteness theorems."}],
    max_tokens=3000,
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

DeepSeek R1 API Pricing

Model Input (per 1M) Output (per 1M)
DeepSeek V4 Pro $0.435 list $0.87 list
DeepSeek V4 Flash $0.14 list $0.28 list

See APIMaster marketplace for current discounted rates.

Get DeepSeek R1 API Access

Frequently Asked Questions

What is DeepSeek R1? DeepSeek R1 is the older name users associate with DeepSeek reasoning. Current API integrations should use DeepSeek V4 thinking mode, which exposes reasoning through reasoning_content.

When should I use DeepSeek R1 instead of V4? Use V4 Pro thinking mode for math, formal logic, science problems, and tasks where reasoning improves accuracy. Use V4 Flash or non-thinking mode for speed-sensitive tasks.

How do I parse DeepSeek R1 thinking output in Python? Read reasoning_content for the reasoning trace and content for the final answer. Avoid relying on <think> tag parsing for current API integrations.

What does DeepSeek R1 cost? Pricing varies by V4 Flash/Pro tier, cache hit rate, and output length. See live APIMaster pricing.

Is DeepSeek R1 available via APIMaster? Yes—use model ID deepseek-v4-pro with APIMaster's OpenAI-compatible endpoint.

Get started → · DeepSeek API Guide → · DeepSeek Pricing →