DeepSeek API

API only — no SDK version · active · verified Tue Mar 24

DeepSeek has NO official Python SDK. The correct integration pattern is using the openai package with base_url='https://api.deepseek.com'. The deepseek PyPI package (1.0.0) is a stub placeholder — do not use it. DeepSeek API is fully OpenAI-compatible. Two primary models: deepseek-chat (V3.2, general purpose) and deepseek-reasoner (R1, chain-of-thought reasoning).

Warnings

Install

Imports

Quickstart

Minimal DeepSeek API call using openai SDK with base_url override.

# pip install openai
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ['DEEPSEEK_API_KEY'],
    base_url='https://api.deepseek.com'
)

response = client.chat.completions.create(
    model='deepseek-chat',
    messages=[
        {'role': 'system', 'content': 'You are a helpful assistant'},
        {'role': 'user', 'content': 'What is the capital of France?'}
    ]
)
print(response.choices[0].message.content)

view raw JSON →