DeepSeek API Basics
Harry
· 13 Sep 2026
· 5 views
Getting an API Key
Create an account on platform.deepseek.com, top up a small amount of balance, and generate an API key from the dashboard. The API follows the OpenAI format, so most existing OpenAI code works by changing the base URL.
Base URL and Models
base_url: https://api.deepseek.com
models: deepseek-chat, deepseek-reasonerSample Request
curl https://api.deepseek.com/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_KEY" -d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello"}]}'Using the Python SDK
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.deepseek.com")
resp = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Explain recursion"}]
)
print(resp.choices[0].message.content)Key Points
- Sign up at platform.deepseek.com and create a key.
- Use the OpenAI-compatible endpoint at api.deepseek.com.
- Pick deepseek-chat for speed or deepseek-reasoner for deep thinking.
- Track usage in the dashboard to manage costs.