← Back to home → All Articles
📂 AI 📅 December 2, 2026 📝 1400 words

Switching Your OpenAI Client to DeepSeek API: base_url, Authentication & Multi-Client Integration Walkthrough (2026)

Any client or framework built against the OpenAI REST spec—Python openai SDK, TypeScript, curl, LangChain, LiteLLM, Continue.dev, and others—can reach DeepSeek's inference endpoints by changing two values: the base URL and the API key. No new SDK is required, and no request format changes. This guide walks through the exact configuration for each major client, explains the model names you need, and covers how high-volume AI platforms can procure access and manage token costs against published list prices.


Why OpenAI Compatibility Matters for Platform Engineers

If your platform already routes traffic through an LLM gateway, an AI agent loop, or a coding assistant framework, adding DeepSeek as a backend is a configuration change—not a rewrite. The OpenAI Chat Completions API shape (/v1/chat/completions, /v1/models, streaming via SSE) is fully replicated at DeepSeek's endpoint. That means your retry logic, token counting, streaming handlers, and function-calling parsers transfer without modification.

For multi-model platforms this is operationally significant: you can shadow-route a percentage of traffic to DeepSeek for cost benchmarking without touching application code—only the base_url and credential in your model router config.


DeepSeek API Endpoint & Model Names

Official base URL (from DeepSeek API docs):

https://api.deepseek.com

Available models at this endpoint:

Pass the model name as the model field in your request body, exactly as listed above.


Integration Examples by Client

1. Python openai SDK

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_DEEPSEEK_API_KEY",
    base_url="https://api.deepseek.com",
)

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarise the key points of this document."},
    ],
    stream=False,
)

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

2. TypeScript / Node.js

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.DEEPSEEK_API_KEY,
  baseURL: "https://api.deepseek.com",
});

const response = await client.chat.completions.create({
  model: "deepseek-flash",
  messages: [{ role: "user", content: "What is 17 × 83?" }],
});

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

3. curl

curl https://api.deepseek.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [{"role": "user", "content": "Hello, DeepSeek."}]
  }'

4. LiteLLM (multi-model router)

# litellm_config.yaml
model_list:
  - model_name: deepseek-flash
    litellm_params:
      model: deepseek/deepseek-flash
      api_key: os.environ/DEEPSEEK_API_KEY
      api_base: https://api.deepseek.com

  - model_name: deepseek-v4-pro
    litellm_params:
      model: deepseek/deepseek-v4-pro
      api_key: os.environ/DEEPSEEK_API_KEY
      api_base: https://api.deepseek.com

Start the proxy with litellm --config litellm_config.yaml. Downstream services call localhost:4000 using standard OpenAI calls; LiteLLM handles routing and retries.

5. LangChain (Python)

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-flash",
    openai_api_key="YOUR_DEEPSEEK_API_KEY",
    openai_api_base="https://api.deepseek.com",
)

result = llm.invoke("Draft an executive summary in three bullet points.")
print(result.content)

Token Cost Reference: DeepSeek List Prices

The table below uses official DeepSeek list prices only (source: api-docs.deepseek.com/quick_start/pricing, prices in USD / 1M tokens, verified 2026-10-11). DeepSeek charges half price during off-peak hours (off-peak = all hours except UTC 01:00–04:00 and 06:00–10:00 on weekdays, excluding Chinese public holidays).

Model Input (cache miss) — Peak Input (cache miss) — Off-peak Input (cache hit) — Peak Output — Peak Output — Off-peak
deepseek-flash $0.30 $0.15 $0.006 $1.20 $0.60
deepseek-v4-pro $1.32 $0.66 $0.044 $3.96 $1.98

All figures are official list prices; your volume rate depends on your usage tier. Prices verified 2026-10-11 from the DeepSeek pricing page linked above.

Worked Cost Example

Assumption: an AI coding platform sends 500M input tokens and generates 150M output tokens per month using deepseek-flash, all at peak rate, no cache hits.

Input cost:  500 × $0.30  = $150.00
Output cost: 150 × $1.20  = $180.00
Total (peak, no cache):    = $330.00 / month

If 60% of input tokens are cache hits:
Cache-hit input:  300 × $0.006 = $1.80
Cache-miss input: 200 × $0.30  = $60.00
Output (unchanged):            = $180.00
Total with cache:              = $241.80 / month

This shows why prompt caching strategy matters at scale—same workload, different cost depending on prompt structure. DeepSeek's context window supports up to 1M tokens, with max output of 384K tokens per request.


Model Selection: deepseek-flash vs deepseek-v4-pro

deepseek-flash deepseek-v4-pro
Suitable for High-volume classification, summarisation, code completion drafts, chat turns where cost per call matters Complex reasoning, multi-step agent tasks, long-context synthesis, production coding assistants
Cost tier Lower (see list prices above) Higher (see list prices above)
Cache benefit High: system prompt caching dramatically cuts input cost on repeated prompts High: same mechanism, particularly useful for long shared system prompts
Recommended routing pattern Default route for most platform traffic Escalation route when flash response quality falls below threshold

If you also need Qwen or GLM behind the same gateway, Vantix's API endpoint lets you access deepseek-flash, deepseek-v4-pro, qwen4-max, qwen3.8-max, qwen3.7-plus, and glm-5.3 under a single key with volume-based pricing. See vantixcloud.com/ai-api for details.


Payment & Procurement for International Teams

DeepSeek's own platform accepts credit cards. If your team is based in Southeast Asia, Hong Kong, Taiwan, or another region where obtaining a foreign-currency credit card for a corporate API account is inconvenient, Vantix accepts USDT (TRC20) prepayment—no registration required to get a quote.

  1. Fill in the quote form at vantixcloud.com/ai-api with your expected monthly token volume and model mix.
  2. Receive a Telegram quote within one business day.
  3. Pay by USDT and receive API credentials—no account sign-up flow required.
  4. Use the credentials in the same base_url + api_key pattern shown above; no code changes.

Volume discounts are negotiated based on monthly usage. Claude, GPT, and Gemini are available on a case-by-case basis—contact via Telegram to discuss requirements.


Q&A

Do I need to install a separate DeepSeek SDK?

No. The standard openai Python package (v1.x) or the TypeScript openai npm package works as-is. Set base_url to https://api.deepseek.com and pass your DeepSeek key as api_key.

Does function calling / tool use work the same way?

Yes. DeepSeek's Chat Completions endpoint supports the tools and tool_choice fields in the same format as the OpenAI spec. Your existing tool-calling parsers should work without modification.

How does off-peak pricing apply in practice?

Off-peak rates apply outside UTC 01:00–04:00 and 06:00–10:00 on weekdays (Chinese public holidays counted as off-peak). Batch jobs scheduled outside these windows at peak cost roughly half the rate. See the DeepSeek pricing page for the definitive schedule.

Can I use the same pattern for Qwen or GLM?

Yes, with different base URLs. Qwen uses Alibaba Cloud Model Studio's endpoint; GLM uses https://api.z.ai/api/paas/v4/. If you want all three under one key with unified invoicing, Vantix's aggregation endpoint handles that routing transparently.

What if I don't have a foreign credit card for top-up?

Vantix's procurement route accepts USDT with no sign-up requirement. Fill in the quote form or message @sapporo168 on Telegram with your monthly volume estimate.

Is streaming supported?

Yes. Set stream=True (Python) or stream: true (JSON) and handle the standard SSE chunks exactly as you would with OpenAI's streaming responses.


Get a Volume Quote

If you're building an AI agent platform, coding assistant, multi-model gateway, or any other product with sustained token consumption, the per-token economics at scale are worth evaluating with actual volume figures rather than list prices alone.

Fill in the quote form at vantixcloud.com/ai-api with your monthly token volume and model mix. Alternatively, reach out directly on Telegram: @sapporo168. Quotes are delivered via Telegram; USDT payment accepted; no registration required.

AI models, CDN, live streaming, anti-DDoS, cloud: get a discount quote for your volume. No sign-up.

Get a quote → Telegram @sapporo168