DeepSeek OpenAI-Compatible Endpoint Setup Guide: base_url, API Key & Multi-Model Routing for AI Platforms 2026
DeepSeek exposes a fully OpenAI-compatible REST API at https://api.deepseek.com, meaning any SDK or framework that accepts a custom base_url — LangChain, LlamaIndex, LiteLLM, or plain openai Python/Node — connects without code changes beyond swapping the endpoint and key. For AI gateway, agent, and coding-tool platforms in Southeast Asia, Hong Kong, or anywhere without easy access to Alipay or a mainland Chinese bank account, this compatibility layer plus USDT-based top-up via a reseller is the fastest path to production. This guide covers the exact configuration steps, model identifiers, caching mechanics, off-peak pricing logic, and how to fit DeepSeek into a multi-model routing architecture alongside Qwen and GLM.
1. Endpoint & Authentication Basics
DeepSeek's official base URL is https://api.deepseek.com (documented at api-docs.deepseek.com). Authentication uses a standard Bearer token in the Authorization header — the same pattern as OpenAI.
Python (openai SDK)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DEEPSEEK_KEY",
base_url="https://api.deepseek.com"
)
response = client.chat.completions.create(
model="deepseek-chat", # maps to deepseek-v4-pro
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
Node.js (openai SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com",
});
const res = await client.chat.completions.create({
model: "deepseek-chat",
messages: [{ role: "user", content: "Hello" }],
});
LiteLLM (multi-model gateway)
import litellm
response = litellm.completion(
model="openai/deepseek-chat",
api_base="https://api.deepseek.com",
api_key="YOUR_DEEPSEEK_KEY",
messages=[{"role": "user", "content": "Hello"}]
)
No other parameters need to change. temperature, max_tokens, stream, tools, and response_format all pass through identically.
2. Model Names to Use
DeepSeek currently exposes two production models on the compatible endpoint (verified 2026-10-11 via api-docs.deepseek.com):
- deepseek-chat — resolves to deepseek-v4-pro. Use this for complex reasoning, long-form generation, agentic tasks.
- deepseek-reasoner — the chain-of-thought variant. Useful for math, code review, structured analysis.
- For deepseek-flash (V4.1-Flash), pass
model="deepseek-flash"directly as the model string.
Always confirm the latest model string aliases in the official docs before deploying to production, since alias mappings can update without notice.
3. Understanding Off-Peak Pricing & Prompt Caching
DeepSeek's pricing has two levers that matter enormously for platform-scale token budgets.
Off-Peak Half-Price Window
Off-peak applies outside UTC 01:00–04:00 and 06:00–10:00 Monday–Friday (Chinese public holidays excluded). During off-peak, all input and output prices are halved. Batch jobs, nightly fine-tuning prep, or background agent tasks scheduled in these windows cut costs by 50% with zero code change.
Prompt Cache
DeepSeek charges cache-hit input tokens at roughly 2% of the uncached input price. For AI companion platforms or coding tools with a long system prompt repeated across sessions, this is the single largest cost lever available. Structure your prompts so the static prefix (system prompt + few-shot examples) comes first and the dynamic user content comes last — the cache hit rate maximises automatically.
Worked Example (illustrative, not a quote)
Assumptions: 10M input tokens/day, 70% cache hit rate, 3M output tokens/day, all off-peak (deepseek-v4-pro, prices per 1M tokens from FACTS verified 2026-10-11).
- Cache-hit input: 7M × $0.022 = $0.154
- Cache-miss input: 3M × $0.66 = $1.98
- Output: 3M × $1.98 = $5.94
- Daily total ≈ $8.07
Without cache and at peak rates (input $1.32 uncached, output $3.96): 10M × $1.32 + 3M × $3.96 = $13.20 + $11.88 = $25.08/day. The combined effect of caching + off-peak scheduling is a ~68% reduction in this scenario.
4. Multi-Model Routing: When to Prefer Qwen or GLM
A well-designed AI gateway doesn't route everything to one model. The comparison below is intentionally specification-free — it focuses on use-case fit and compatibility posture, not on raw numbers outside the FACTS block.
| Criterion | DeepSeek V4 Pro / Flash | Qwen3.7-Max / 3.8-Max | GLM-5.2 / GLM-4.7 |
|---|---|---|---|
| OpenAI-compatible base_url | ✅ api.deepseek.com | ✅ DashScope (intl) | ✅ api.z.ai/api/paas/v4/ |
| Best fit for | Agent reasoning, coding tools, long context chat | Multilingual SaaS, structured output, image understanding | Lightweight companion, OCR pipelines, cost-sensitive fallback |
| Off-peak / caching discount | 50% off-peak + ~2% cache-hit input | Cache-hit ~10% of input price; no time-of-day tier | Flat rate; glm-4.7-flash currently free tier available |
| Payment without foreign card | USDT via reseller or direct top-up | USDT via reseller or Alipay intl | USDT via reseller |
| Claude / GPT / Gemini | Available on request — per-project pricing, contact for details | ||
For platforms building a model-routing layer, a practical pattern is: route high-complexity tasks to deepseek-v4-pro, medium tasks to qwen3.7-plus or glm-5.2, and simple classification or triage to deepseek-flash or glm-4.7-flash. All three share the same OpenAI SDK interface, so the only routing variable is the model string and base_url.
If you need a managed aggregation layer rather than self-routing, Vantix Cloud's AI API hub gives you a single key across DeepSeek, Qwen, and GLM with USDT or card top-up and volume-based pricing — no registration wall, no Alipay required.
5. Environment Variable Best Practice for Platform Teams
# .env for multi-provider setup
DEEPSEEK_API_KEY=sk-xxx
DEEPSEEK_BASE_URL=https://api.deepseek.com
QWEN_API_KEY=sk-yyy
QWEN_BASE_URL=https://dashscope-intl.aliyuncs.com/compatible-mode/v1
GLM_API_KEY=sk-zzz
GLM_BASE_URL=https://api.z.ai/api/paas/v4/
Inject these at runtime via your secret manager (AWS Secrets Manager, GCP Secret Manager, or Doppler). This way your routing logic only switches the env var reference — the SDK call stays identical.
6. Common Integration Mistakes to Avoid
- Hardcoding the wrong model alias. DeepSeek's
deepseek-chatis a pointer that may update. Pin your alias in config, not scattered across handlers. - Ignoring cache structure. If your dynamic content precedes the system prompt, you get zero cache benefit. Always put static content first.
- Scheduling batch jobs at peak hours. Peak = UTC 01:00–04:00 and 06:00–10:00 Mon–Fri. Moving nightly jobs outside these windows requires no code change and halves the bill.
- Using the same key for dev and prod. Rate limits and spend caps apply per key. Separate them from day one.
- Assuming Claude/GPT/Gemini work via the same base_url swap. They do not — these models require separate arrangements. Contact us for per-project scoping.
Q&A
Q: Can I use DeepSeek with LangChain without rewriting my chain?
Yes. Pass base_url="https://api.deepseek.com" and your DeepSeek key to ChatOpenAI(). The rest of your chain is unchanged.
Q: Does streaming work on the DeepSeek compatible endpoint?
Yes. Set stream=True (Python) or stream: true (JS) exactly as you would with OpenAI. Server-sent events are returned in the same format.
Q: How do I pay for DeepSeek API access without a mainland Chinese bank account or Alipay?
Direct top-up on api.deepseek.com accepts Alipay and cards — not always accessible outside mainland China. Via Vantix, you can top up with USDT or a regular credit card with no registration required. Submit a quote request or message Telegram @sapporo168.
Q: Is there a free trial or low-minimum top-up?
DeepSeek's direct platform offers a new-account credit period — check their official site for current terms. Via Vantix, minimum top-up and volume discounts are quoted per team; fill the form and we'll respond on Telegram.
Q: Do Qwen and GLM use the same setup pattern?
Yes — both expose OpenAI-compatible endpoints. Swap base_url and api_key; the SDK call is identical. See the environment variable block above.
Q: Can I route to multiple models from a single Vantix key?
Contact us to confirm current key architecture — this varies by plan. Reach out via the quote form or Telegram.
Get Started with DeepSeek API via Vantix
If you're an AI platform, agent framework, or coding-tool team ready to route production traffic through DeepSeek — with USDT payment, no registration wall, and volume pricing — fill in the quote form at vantixcloud.com/models/deepseek-api/. We respond via Telegram, typically fast.
You can also message us directly: Telegram @sapporo168 — include your expected monthly token volume and which models you need, and we'll quote accordingly.