What This Guide Covers
DeepSeek, Qwen (Alibaba Cloud international), and GLM (Z.ai international) all expose OpenAI-compatible REST endpoints. If your platform is built on the OpenAI Python or Node SDK, switching to any of these models requires changing only base_url and api_key — your retry logic, streaming handlers, and observability hooks stay unchanged. This guide covers endpoint configuration, model identifiers, prompt-caching mechanics, off-peak scheduling, multi-model routing patterns, and payment options for teams outside mainland China.
All token prices below are official provider list prices verified 2026-10-25. They are not VantixCloud prices. Sources are linked inline.
Endpoint Reference
| Provider | OpenAI-Compatible base_url |
Official Pricing Source |
|---|---|---|
| DeepSeek | https://api.deepseek.com |
api-docs.deepseek.com/quick_start/pricing |
| Qwen (Alibaba Cloud intl, Singapore) | https://dashscope-intl.aliyuncs.com/compatible-mode/v1 |
alibabacloud.com/help/en/model-studio/model-pricing |
| GLM (Z.ai intl) | https://api.z.ai/api/paas/v4/ |
docs.z.ai/guides/overview/pricing |
Official List Prices (USD / 1M tokens, verified 2026-10-25)
DeepSeek — source
DeepSeek applies a peak / off-peak split: peak = Monday–Friday UTC 01:00–04:00 and 06:00–10:00; all other hours are off-peak at half the peak price.
| Model | Input — cache hit (peak / off-peak) | Input — cache miss (peak / off-peak) | Output (peak / off-peak) |
|---|---|---|---|
| deepseek-flash | $0.006 / $0.003 | $0.30 / $0.15 | $1.20 / $0.60 |
| deepseek-v4-pro | $0.044 / $0.022 | $1.32 / $0.66 | $3.96 / $1.98 |
Qwen — Alibaba Cloud international, Singapore region — source
Qwen prices tier by single-request input length. The values below are standard list prices for the stated tiers.
| Model | Input tier | Input (per 1M) | Output (per 1M) |
|---|---|---|---|
| qwen3.8-max | 0–1M tokens | $2.00 | $6.00 |
| qwen3.7-max | 0–1M tokens | $2.50 | $7.50 |
| qwen3.7-plus | 0–256K tokens | $0.40 | $1.60 |
| qwen3.7-plus | 256K–1M tokens | $1.20 | $4.80 |
| qwen-flash | 0–256K tokens | $0.05 | $0.40 |
GLM — Z.ai international — source
| Model | Input (per 1M) | Cache input (per 1M) | Output (per 1M) |
|---|---|---|---|
| glm-5.2 / glm-5.3 | $1.40 | $0.26 | $4.40 |
| glm-4.7 | $0.60 | — | $2.20 |
Step-by-Step: Connecting with the OpenAI SDK
Step 1 — Store credentials in environment variables
# .env — 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, Doppler, or equivalent). Your routing logic then switches only the environment-variable reference — the SDK call stays identical across providers.
Step 2 — Python (openai SDK)
import os
from openai import OpenAI
# Swap the two variables below to switch provider
client = OpenAI(
api_key=os.environ["DEEPSEEK_API_KEY"],
base_url=os.environ["DEEPSEEK_BASE_URL"]
)
response = client.chat.completions.create(
model="deepseek-v4-pro", # see model identifiers below
messages=[{"role": "user", "content": "Summarise this contract."}],
stream=False
)
print(response.choices[0].message.content)
temperature, max_tokens, stream, tools, and response_format all pass through identically to each provider's compatible endpoint.
Step 3 — Node.js (openai SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: process.env.DEEPSEEK_BASE_URL,
});
const res = await client.chat.completions.create({
model: "deepseek-v4-pro",
messages: [{ role: "user", content: "Summarise this contract." }],
});
console.log(res.choices[0].message.content);
Step 4 — LiteLLM (multi-model gateway)
import litellm
response = litellm.completion(
model="openai/deepseek-v4-pro",
api_base="https://api.deepseek.com",
api_key="YOUR_DEEPSEEK_KEY",
messages=[{"role": "user", "content": "Summarise this contract."}]
)
Step 5 — curl (health-check / CI)
curl https://api.deepseek.com/chat/completions \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [{"role": "user", "content": "ping"}]
}'
Replace https://api.deepseek.com and the key variable with the Qwen or GLM equivalents to test those endpoints identically.
DeepSeek Prompt Caching & Off-Peak Scheduling
How caching works
DeepSeek charges cache-hit input tokens at roughly 2% of the uncached input price (e.g., $0.022 vs $1.32 per 1M for deepseek-v4-pro at peak). To maximise cache hit rate, structure prompts so the static content (system prompt, few-shot examples) appears first and dynamic user content appears last. The cache match is based on a prefix match of the token sequence.
Off-peak scheduling
Off-peak hours — all times outside Monday–Friday UTC 01:00–04:00 and 06:00–10:00 — carry exactly half the peak price on both input and output. Moving batch jobs, nightly summarisation runs, or background agent tasks to off-peak windows requires no code change.
Worked cost example (illustrative — not a provider quote)
Assumptions: deepseek-v4-pro, 10M input tokens/day, 70% cache hit rate, 3M output tokens/day, all traffic scheduled off-peak. Prices from api-docs.deepseek.com, verified 2026-10-25.
- Cache-hit input: 7,000,000 × $0.022 / 1,000,000 = $0.154
- Cache-miss input: 3,000,000 × $0.66 / 1,000,000 = $1.98
- Output: 3,000,000 × $1.98 / 1,000,000 = $5.94
- Daily total ≈ $8.07
Same volume, no caching, at peak rates (uncached input $1.32, output $3.96):
- Input: 10,000,000 × $1.32 / 1,000,000 = $13.20
- Output: 3,000,000 × $3.96 / 1,000,000 = $11.88
- Daily total ≈ $25.08
In this scenario, combining cache structuring with off-peak scheduling reduces the daily spend from ~$25.08 to ~$8.07 — a difference driven entirely by configuration choices, not model changes.
Multi-Model Routing: Use-Case Fit
A practical AI gateway routes by task type rather than sending everything to one model. All three provider families share the same OpenAI SDK interface; the only routing variables are model and base_url.
| Task type | Suggested model | Rationale |
|---|---|---|
| Complex reasoning, agent orchestration, code generation | deepseek-v4-pro | Strong multi-step reasoning; off-peak + caching reduces cost at volume |
| High-throughput classification, autocomplete, first-turn chat | deepseek-flash | Lower per-token cost; off-peak half-price still applies |
| Multilingual SaaS, structured output, image + text input | qwen3.7-plus or qwen3.8-max | Strong Southeast Asian language coverage; multimodal support |
| Enterprise document Q&A, OCR pipelines, cost-sensitive fallback | glm-5.2 or glm-4.7 | Flat rate with cache pricing on glm-5.x; glm-4.7 is lower cost for lighter tasks |
| Claude / GPT / Gemini family | Available on request — contact for per-project scoping | |
For teams that want a managed aggregation layer rather than self-routing, VantixCloud's AI API service covers DeepSeek, Qwen, and GLM under a single commercial arrangement, with USDT or card payment and no registration wall required.
Common Integration Mistakes
- Hardcoding model alias strings across handlers. Pin model identifiers in a central config file. Alias mappings (e.g.,
deepseek-chatas a pointer) can update without notice — verify against the official docs before each production deployment. - Putting dynamic content before the system prompt. DeepSeek's cache match is prefix-based. If user content precedes your static system prompt, you get zero cache benefit. Always put static content first.
- Running batch jobs during DeepSeek peak hours. Peak = UTC 01:00–04:00 and 06:00–10:00, Monday–Friday. Scheduling outside these windows halves input and output costs with no code change.
- Sharing one API key across dev and prod. Rate limits and spend caps apply per key. Separate keys from day one to avoid production interruptions caused by dev testing.
- Assuming Claude, GPT, or Gemini work via a simple base_url swap. These families require separate arrangements and do not share the same authentication model as the providers covered here.
Q&A
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 LangChain chain, including tools, memory, and callbacks, is unchanged.
Does streaming work on all three compatible endpoints?
Yes. Set stream=True (Python) or stream: true (JS/Node) exactly as you would with OpenAI. Server-sent events are returned in the same format across DeepSeek, Qwen, and GLM.
How do I pay for API access without a mainland Chinese bank account or Alipay?
DeepSeek's direct platform (api-docs.deepseek.com) accepts Alipay and cards; availability varies by region. Alibaba Cloud international (Qwen) and Z.ai international (GLM) both offer card payment for registered accounts. For teams that need USDT top-up or prefer a single billing arrangement across providers, submit a quote request at VantixCloud or message Telegram @sapporo168 — no registration required to enquire.
Do Qwen and GLM use the same SDK call structure as DeepSeek?
Yes. Swap base_url and api_key; everything else in the SDK call — model parameters, streaming, tool calls, response parsing — is identical. The environment variable pattern in Step 1 above is designed for exactly this.
How does DeepSeek's cache-hit pricing compare to uncached?
Cache-hit input tokens are priced at approximately 2% of the uncached input rate. For deepseek-v4-pro at peak: cache hit = $0.044/1M vs uncached = $1.32/1M (source, verified 2026-10-25). The worked example in the caching section above shows the combined impact at realistic platform volumes.
Which model is appropriate for structured JSON output generation?
All three providers support response_format: { type: "json_object" } on their compatible endpoints. GLM (glm-5.2/5.3) and DeepSeek (deepseek-v4-pro) both have documented support for this parameter — verify the current status in each provider's API reference before production deployment, as feature parity can lag between providers.
Get a Quote or Ask a Question
If your team needs USDT payment, a single commercial arrangement across DeepSeek, Qwen, and GLM, or help sizing token volumes before committing — fill in the quote form at vantixcloud.com/models/deepseek-api/. Include your expected monthly token volume and the models you need, and pricing will be quoted accordingly. You can also message directly via Telegram @sapporo168.