DeepSeek API Guide: V3 & R1 Setup, Pricing, and Code Examples (2026)
Call the cheapest high-performance AI models from Python, Node.js, Cursor, LangChain, and any OpenAI-compatible tool.
DeepSeek has emerged as one of the most disruptive AI model families of 2025-2026, offering performance that rivals GPT-4o and Claude at a fraction of the cost. Whether you need a budget-friendly chatbot backend, a powerful coding assistant, or a reasoning engine for complex problems, DeepSeek delivers exceptional value.
DeepSeek Model Overview
DeepSeek offers two primary models, each designed for different use cases:
| Model | Best For | Input / 1M | Output / 1M | Key Feature |
|---|---|---|---|---|
| DeepSeek-V3 | Chat, coding, analysis, general tasks | $0.14 | $0.28 | Best price-to-performance ratio |
| DeepSeek-R1 | Math, logic, complex reasoning | $0.55 | $2.19 | Visible chain-of-thought reasoning |
DeepSeek-V3 vs DeepSeek-R1: Which to Choose?
- DeepSeek-V3 (
deepseek-chat): Use for 90% of tasks — chatbots, content generation, code writing, summarization, translation, data extraction. It is fast, affordable, and high-quality. - DeepSeek-R1 (
deepseek-reasoner): Reserve for problems that require deep step-by-step reasoning — complex math proofs, multi-constraint logic puzzles, intricate debugging, and scientific analysis. It is slower and more expensive but produces more accurate answers on hard problems.
Quick Start: Python
from openai import OpenAI
client = OpenAI(
api_key="your-token1-us-key",
base_url="https://discount-token.com/v1"
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to reverse a linked list."}
],
max_tokens=1024
)
print(response.choices[0].message.content)
print(f"\nTokens: {response.usage.total_tokens}")
Streaming Response
stream = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Explain Big-O notation."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Quick Start: Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-token1-us-key",
baseURL: "https://discount-token.com/v1",
});
const response = await client.chat.completions.create({
model: "deepseek-chat",
messages: [{ role: "user", content: "Explain Big-O notation simply." }],
});
console.log(response.choices[0].message.content);
Quick Start: curl
curl https://discount-token.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-token1-us-key" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Using DeepSeek-R1 for Complex Reasoning
DeepSeek-R1 includes a visible chain-of-thought reasoning process. The model thinks step by step before producing the final answer, which you can see in the output:
response = client.chat.completions.create(
model="deepseek-reasoner",
messages=[{
"role": "user",
"content": "A farmer has 100 meters of fencing. What is the largest rectangular area they can enclose?"
}],
max_tokens=4096
)
# R1's response includes the reasoning process
print(response.choices[0].message.content)
Using DeepSeek with Popular Tools
Cursor IDE
Set Cursor's OpenAI Base URL to https://discount-token.com/v1 and enter your Token1.US API key. Select deepseek-chat as the model for affordable, high-quality code assistance that costs 90% less than GPT-4o.
LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="deepseek-chat",
api_key="your-token1-us-key",
base_url="https://discount-token.com/v1"
)
response = llm.invoke("What are the SOLID principles?")
Continue (VS Code Extension)
Add a custom model in Continue's config:
{
"models": [{
"title": "DeepSeek-V3",
"provider": "openai",
"model": "deepseek-chat",
"apiBase": "https://discount-token.com/v1",
"apiKey": "your-token1-us-key"
}]
}
Dify
Add a model provider with base URL https://discount-token.com/v1 and your Token1.US API key. DeepSeek will be available as a model option in all Dify apps.
DeepSeek API Pricing: How Much Does It Cost?
DeepSeek is the cheapest high-quality AI API available. Here is what real-world usage costs:
| Scenario | Input Tokens | Output Tokens | Cost (V3) |
|---|---|---|---|
| Single chat message | 50 | 200 | $0.0001 |
| Code generation | 200 | 500 | $0.0002 |
| 1,000 API calls | 50,000 | 200,000 | $0.063 |
| 10,000 API calls | 500,000 | 2,000,000 | $0.63 |
| 100,000 API calls | 5,000,000 | 20,000,000 | $6.30 |
What DeepSeek Excels At
Coding and Programming
DeepSeek-V3 performs excellently on coding benchmarks, often matching GPT-4o. It is particularly strong at:
- Python, JavaScript/TypeScript, Java, C++, Go, Rust
- Algorithm implementation and optimization
- Debugging and error fixing
- Code refactoring and documentation
- SQL query generation
Chinese Language Tasks
DeepSeek was developed by a Chinese AI lab, giving it native-level Chinese understanding. For Chinese-language applications — chatbots, content generation, sentiment analysis — DeepSeek outperforms most Western models.
Bilingual Processing
DeepSeek handles mixed Chinese-English content naturally. If your application processes both languages (e.g., translation tools, international chatbots), DeepSeek is an excellent choice.
Mathematical Reasoning
DeepSeek-R1 is specifically trained for mathematical and logical reasoning. On math benchmarks, it competes with OpenAI's o1 model at a fraction of the cost.
DeepSeek vs Other AI Models
| Feature | DeepSeek-V3 | GPT-4o | Claude Sonnet | GLM-4-Plus |
|---|---|---|---|---|
| Input price | $0.14/1M | $2.50/1M | $3.00/1M | $0.70/1M |
| Output price | $0.28/1M | $10/1M | $15/1M | $0.70/1M |
| Coding quality | Excellent | Excellent | Excellent | Very good |
| Chinese language | Excellent | Good | Good | Best |
| Context window | 64K | 128K | 200K | 128K |
| Best value | Yes | No | No | Good |
For a full comparison, see our detailed model comparison page.
Best Practices for DeepSeek API
- Use V3 by default: It covers 90% of use cases at the lowest cost. Switch to R1 only when you need deep reasoning.
- Leverage cost savings: Route bulk processing tasks to DeepSeek-V3 instead of GPT-4o to save 90%+ on API costs.
- Handle context limits: DeepSeek-V3 supports 64K tokens of context. For longer inputs, chunk your data.
- Use streaming: DeepSeek streams efficiently, improving perceived latency for chat applications.
- Implement caching: DeepSeek is so cheap that caching may seem unnecessary, but for high-volume identical queries, it still saves money.
- Batch processing: For data labeling or classification, DeepSeek-V3 is ideal due to its low cost per token.
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid API key | Check your key in the dashboard |
429 Too Many Requests | Rate limit exceeded | Add delays between requests |
model_not_found | Wrong model name | Use deepseek-chat or deepseek-reasoner |
| R1 too slow | Reasoning model thinks deeply | Use V3 for time-sensitive tasks |
Frequently Asked Questions
What is the DeepSeek API?
The DeepSeek API provides programmatic access to DeepSeek AI models: DeepSeek-V3 for general chat and coding, and DeepSeek-R1 for complex reasoning. It is OpenAI-compatible and accessible through Token1.US.
How much does the DeepSeek API cost?
DeepSeek-V3 costs approximately $0.14/1M input and $0.28/1M output — the cheapest high-quality AI API available. DeepSeek-R1 costs $0.55/1M input and $2.19/1M output. See our pricing comparison.
Is DeepSeek API compatible with the OpenAI SDK?
Yes. DeepSeek API is fully OpenAI-compatible. Use the standard OpenAI SDK with base_url="https://discount-token.com/v1". All features work identically.
What is the difference between DeepSeek-V3 and DeepSeek-R1?
DeepSeek-V3 is a general-purpose model optimized for speed and cost. DeepSeek-R1 is a reasoning model that thinks step-by-step, making it better for math, logic, and complex coding but slower and more expensive.
Is DeepSeek good for coding?
Yes. DeepSeek-V3 performs excellently on coding benchmarks, often matching or exceeding GPT-4o. For coding tasks, DeepSeek offers the best value — similar quality at 95% lower cost.
Can I use DeepSeek with Cursor or LangChain?
Yes. Set the OpenAI base URL to https://discount-token.com/v1 in Cursor settings, or use base_url in LangChain. DeepSeek works with all OpenAI-compatible tools.
Is DeepSeek safe to use for production?
Yes. DeepSeek models are served through Token1.US with 99.9% uptime, global CDN, and HTTPS encryption. Request logs are retained for only 7 days. No content is permanently stored.
Start Building with DeepSeek
The cheapest high-quality AI API. 95% cheaper than GPT-4o.
Get Your API Key