Everyone keeps saying "DeepSeek is so cheap," but most tutorials jump straight into the advanced stuff. So here's the version I wish I'd had on day one — from zero to your first working API call, no prior experience needed.
Two reasons DeepSeek is a great first API to learn on:
- It's cheap. Like, an order of magnitude cheaper than the big US models. You can experiment all day without watching a meter.
- It's OpenAI-compatible. If you've ever seen OpenAI's Python code, you already know how to use this — you change two lines. So the skill transfers everywhere.
Let's get you a working call.
Step 1 — Get your API key
Go to platform.deepseek.com, sign up, open the API Keys page, and create a new key. Copy it right away — you only see it once. Then save it as an environment variable instead of pasting it into your code:
export DEEPSEEK_API_KEY="your_key_here"
(Never hardcode a key into a file you might push to GitHub. People scrape for leaked keys.)
Step 2 — Install the SDK
pip install openai
Yes, the OpenAI SDK. DeepSeek speaks the same protocol, so we reuse it.
Step 3 — Your first call
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("DEEPSEEK_API_KEY"),
base_url="https://api.deepseek.com",
)
response = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain what an API is in one sentence."},
],
)
print(response.choices[0].message.content)
That's it. The only things that make this "DeepSeek" instead of "OpenAI" are the base_url and the model. Everything else is identical.
Not a Python person? (curl)
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello!"}]
}'
The part that surprised me: the price
DeepSeek V4 Flash runs about $0.14 per million input tokens and $0.28 per million output tokens. A million tokens is roughly 750,000 words. So a full day of heavy experimenting costs you cents, not dollars.
For comparison, the flagship GPT and Claude models can cost 10x+ that on output. For learning, side projects, and honestly most production workloads, the cheap tier is genuinely good enough. (Cache hits are billed at 1/10 the input price, which adds up fast if you reuse prompts.)
A few beginner gotchas
-
Use the model name
deepseek-v4-flash. The olddeepseek-chatalias still works but is being retired on July 24, 2026 — a lot of older tutorials still use it. - You need to add a little credit before it works. There's no unlimited free tier.
- "OpenAI-compatible" ≠ OpenAI. A few niche parameters differ, but the basics above are identical.
- Keep your key out of git. Worth saying twice.
Wrap-up
You now have a working, dirt-cheap AI API and code that transfers to almost any other model. Go build something.
What are you making with it? And if you're outside the US — was getting set up easy, or was payment/signup the hard part? Curious how common that is.
Top comments (0)