๐Ÿ“˜ DeepSeek API Tutorial โ€” Complete Guide 2026

Everything you need to start using DeepSeek V4, V3, and R1 in your applications. From setup to production-ready code examples.

Get DeepSeek API Key โ†’

1 Get Your API Key

Sign up at AI Token to get your API key. You'll have immediate access to DeepSeek V4, V3, R1, and 8 other models.

Free tier available โ€” no credit card required to start.

2 Basic API Call (Python)

# Install the OpenAI SDK (DeepSeek uses the same format)
# pip install openai

from openai import OpenAI

client = OpenAI(
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    api_key="your-api-key-here"
)

# DeepSeek V4 โ€” Best for coding and complex tasks
response = client.chat.completions.create(
    model="deepseek-v4",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a Python function to sort a list."}
    ],
    temperature=0.7
)

print(response.choices[0].message.content)

3 Using DeepSeek R1 for Reasoning

# DeepSeek R1 โ€” Chain-of-thought reasoning model
# Perfect for math, logic, and multi-step problems

response = client.chat.completions.create(
    model="deepseek-r1",
    messages=[
        {"role": "user", "content": """
        A train travels at 60 km/h for 2.5 hours,
        then at 80 km/h for 1.5 hours.
        What is the average speed for the entire journey?
        """}
    ]
)

# R1 shows its reasoning process
print(response.choices[0].message.content)

4 JavaScript / Node.js

// npm install openai
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1',
  apiKey: 'your-api-key-here'
});

const response = await client.chat.completions.create({
  model: 'deepseek-v4',
  messages: [
    { role: 'user', content: 'Explain quantum computing in simple terms' }
  ]
});

console.log(response.choices[0].message.content);

5 Available DeepSeek Models

ModelBest ForSpeed
deepseek-v4Coding, complex tasksMedium
deepseek-v3General purposeMedium
deepseek-r1Math, reasoning, logicSlow
deepseek-v4-flashQuick tasks, chatbotsFast

6 Streaming Responses

# Stream responses for better UX
stream = client.chat.completions.create(
    model="deepseek-v4",
    messages=[{"role": "user", "content": "Write a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
Start Using DeepSeek API Now โ†’