DeepSeek API key setup

Published 2026-10-08 · Updated 2026-10-21

A DeepSeek key is sk- followed by 32 lowercase hex characters, 35 characters total. It looks a lot like an old OpenAI key, which is why double-checking the base URL matters.

Setup

export DEEPSEEK_API_KEY="sk-..."

Base URL: https://api.deepseek.com/v1. DeepSeek is fully OpenAI-compatible.

Verify it

curl https://api.deepseek.com/v1/models \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY"

Python

from openai import OpenAI
import os

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

resp = client.chat.completions.create(
    model="deepseek-v4",
    messages=[{"role": "user", "content": "Say hello"}],
)
print(resp.choices[0].message.content)

Worth knowing

If a key lists models but fails on chat with Insufficient Balance, the key is real but empty. Move to the next one.