DeepSeek has quietly become one of the most important AI providers for cost-conscious developers. Their V3 model delivers GPT-4-class performance at a fraction of the cost — and their R1 reasoning model competes with Claude Opus on benchmarks.
Here's everything you need to know to start using the DeepSeek API.
DeepSeek Models Overview
| Model | Type | Input/1M tokens | Output/1M tokens | Context | Best For |
|---|---|---|---|---|---|
| DeepSeek V3 | General | $0.27 | $1.10 | 128K | Bulk tasks, general coding |
| DeepSeek R1 | Reasoning | $0.55 | $2.19 | 128K | Complex reasoning, math, code |
For comparison:
- Claude Sonnet 4.6: $3.00 / $15.00 — 11x more expensive than V3
- GPT-5.5: $3.00 / $12.00 — 11x more expensive than V3
Quick Start
DeepSeek's API is OpenAI-compatible, which means you can use the standard OpenAI SDK:
Python
pip install openai
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepseek.com/v1",
api_key="your-deepseek-api-key"
)
response = client.chat.completions.create(
model="deepseek-chat", # This is V3
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to merge two sorted arrays"}
],
max_tokens=1024
)
print(response.choices[0].message.content)
Node.js
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.deepseek.com/v1',
apiKey: 'your-deepseek-api-key'
});
const response = await client.chat.completions.create({
model: 'deepseek-chat',
messages: [
{ role: 'user', content: 'Explain async iterators in JavaScript' }
]
});
console.log(response.choices[0].message.content);
cURL
curl https://api.deepseek.com/v1/chat/completions \
-H "Authorization: Bearer your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello, DeepSeek!"}]
}'
Using DeepSeek R1 (Reasoning Model)
DeepSeek R1 is their reasoning-focused model — think of it as DeepSeek's answer to Claude Opus or o3. It's great for math, logic, and complex coding problems.
response = client.chat.completions.create(
model="deepseek-reasoner", # R1
messages=[
{"role": "user", "content": "Prove that there are infinitely many primes"}
],
max_tokens=4096
)
R1 costs about 2x more than V3 ($0.55/$2.19 vs $0.27/$1.10) but is still dramatically cheaper than Claude Opus ($5/$25).
Streaming
stream = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Write a REST API in FastAPI"}],
stream=True
)
for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="")
When to Use DeepSeek (and When Not To)
Use DeepSeek V3 for:
- Test generation — 90%+ of the quality at 10% of the cost
- Documentation — Writing docstrings, READMEs, comments
- Boilerplate — CRUD endpoints, form components, config files
- Translation — Code or text translation between languages
- Data processing — Parsing, cleaning, transforming text data
Don't use DeepSeek for:
- Security-critical code — Use Claude or GPT for auth, encryption
- Complex architecture — Multi-system design needs stronger reasoning
- Production-critical decisions — When wrong answers have high cost
- Sensitive data — Check DeepSeek's data policies for your jurisdiction
Use DeepSeek R1 for:
- Math and logic problems — Competitive with o3 at 5x lower cost
- Algorithm design — Strong at dynamic programming, graph algorithms
- Code debugging — Good at step-by-step analysis of bugs
Cost Optimization Tips
1. Pair DeepSeek with Claude/GPT
Don't use one model for everything. Route tasks based on complexity:
def get_model_for_task(task_type):
if task_type in ["refactor", "debug", "architecture"]:
return "claude-sonnet-4-6" # Worth the premium
elif task_type in ["tests", "docs", "boilerplate"]:
return "deepseek-chat" # 11x cheaper
elif task_type in ["json", "extract", "schema"]:
return "gpt-5.5" # Best structured output
return "deepseek-chat" # Default to cheapest
2. Use via a Gateway (30% cheaper)
Multi-model gateways offer DeepSeek at discounted rates:
# Direct: $0.27/$1.10 per 1M tokens
# Via gateway: $0.19/$0.77 per 1M tokens (30% off)
client = OpenAI(
base_url="https://api.futurmix.ai/v1", # gateway
api_key="your-gateway-key"
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "..."}]
)
3. Batch Similar Requests
# Instead of 50 separate calls:
functions = ["def foo():", "def bar():", ...]
# Batch into one call:
all_funcs = "\n\n".join(functions)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": f"Add docstrings:\n{all_funcs}"}]
)
Using DeepSeek with AI Coding Tools
DeepSeek works with all major AI coding tools through the OpenAI-compatible API:
Aider
aider --openai-api-base https://api.deepseek.com/v1 \
--openai-api-key your-key \
--model openai/deepseek-chat
Or via gateway:
# .aider.conf.yml
openai-api-base: https://api.futurmix.ai/v1
openai-api-key: your-gateway-key
model: openai/deepseek-chat
Codex CLI
export OPENAI_BASE_URL="https://api.deepseek.com/v1"
export OPENAI_API_KEY="your-deepseek-key"
codex --model deepseek-chat "generate tests for src/utils/"
Cursor
Settings → Models → Add custom model:
- API Base:
https://api.deepseek.com/v1 - Model:
deepseek-chat
DeepSeek vs Claude vs GPT: Quick Benchmark
For a standardized coding task (implementing a LRU cache):
| Model | Quality (1-10) | Time (seconds) | Cost per run |
|---|---|---|---|
| Claude Opus 4.7 | 9.5 | 8.2 | $0.15 |
| Claude Sonnet 4.6 | 9.0 | 5.1 | $0.09 |
| GPT-5.5 | 8.5 | 4.3 | $0.07 |
| DeepSeek V3 | 8.0 | 6.7 | $0.008 |
| DeepSeek R1 | 9.0 | 12.1 | $0.016 |
DeepSeek V3 is 80% of Claude's quality at 9% of the cost. For tasks where 80% is good enough (most bulk operations), that's an 11x ROI improvement.
Get Started
You can access DeepSeek either directly or through a multi-model gateway:
Direct:
- Sign up at deepseek.com
- Get your API key
- Use
base_url="https://api.deepseek.com/v1"
Via gateway (30% cheaper, all models in one place):
- Sign up at futurmix.ai
- Get one API key for DeepSeek + Claude + GPT + Gemini
- Use
base_url="https://api.futurmix.ai/v1"
How are you using DeepSeek in production? Share your use cases in the comments.
Top comments (0)