Switching From OpenAI to Chinese Models: A Drop-In Migration Guide

Keep your OpenAI SDK code, change two lines, then verify the parts that are not actually identical.

Because almost every Chinese provider exposes an OpenAI-compatible Chat Completions endpoint, moving code from OpenAI to DeepSeek, Qwen, GLM or Kimi is usually a configuration change rather than a rewrite. The real work is choosing the right model, checking which features you rely on, and validating quality before you switch production traffic.

The two-line change

If you use the official OpenAI SDK, the change is the base URL and the model id:

# before
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# after
client = OpenAI(
    base_url="https://aiapi-pro.com/v1",
    api_key=os.environ["NOVAI_API_KEY"],
)

resp = client.chat.completions.create(
    model="deepseek-v4-flash",   # was "gpt-4o-mini"
    messages=[{"role": "user", "content": "Hello"}],
)

Model ids, context windows and prices are listed at /model-marketplace.html and in the machine-readable feed at /china-ai-leaderboard.json. If you use a framework (LangChain, LlamaIndex, the Vercel AI SDK), it normally reads baseURL from configuration.

Model mapping: a starting point

These are reasonable starting points, not drop-in equivalents. Always re-run your own evaluation set.

If you usedConsiderModel idNotes
GPT-4o-mini (cheap general)DeepSeek V4 Flashdeepseek-v4-flashStrong price/quality for extraction, classification, summarisation
GPT-4o (general)Qwen3.8-Max / DeepSeek V4 Flashqwen3.8-max / deepseek-v4-flashTest both on your prompts; Qwen is strong on multilingual
o-series (reasoning)DeepSeek V4 Pro / GLM-5.3deepseek-v4-pro / glm-5.3Higher latency; visible reasoning where the model supports it
Long-context modelsKimi K2.8/K3kimi-k2.8-preview / kimi-k3Compare cost of a full-context pass before switching
Coding agentsKimi K2.7 Code / DeepSeek V4 Flashkimi-k2.7-code / deepseek-v4-flashTool-calling reliability matters more than raw price
Vision (image input)Qwen3-VL-Plus / GLM-4.6Vqwen3-vl-plus / glm-4.6vCheck image limits and OCR quality per model
Image generationSeedream 5.0doubao-seedream-5.0Billed per image, not per token
Video generationSeedance 2.0 Fastdoubao-seedance-2.0-fastBilled per second/generation; check resolution tiers

Node / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://aiapi-pro.com/v1",
  apiKey: process.env.NOVAI_API_KEY,
});

const res = await client.chat.completions.create({
  model: "deepseek-v4-flash",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);

What breaks (and what to check first)

Feature matrix

CapabilityStatusWhat to verify per model
Chat CompletionsYesBasic sanity, temperature handling
Streaming (SSE)YesEvent sequence, final usage block
Tool / function callingModel-dependentStrict schemas, parallel calls, error recovery
JSON modeModel-dependentSchema conformance on your actual output
Vision inputVision models onlyImage size limits, OCR quality
Long contextModel-dependentReal usable window, truncation behaviour
Image / video generationSeparate endpointsBilling unit (per image / per second), resolution tiers

A safe rollout plan

  1. Build a 50–200 prompt evaluation set from your real traffic (including the ugly edge cases).
  2. Shadow-compare the new model against your current one; score correctness, not just similarity.
  3. Route a small % of traffic with a kill switch and a fallback model in the same client.
  4. Measure cost per successful task rather than cost per token — retries and failures are part of the cost.
  5. Watch latency by region; the fastest route to a provider depends on where your servers are.

For a worked cost comparison of Chinese models on the same task, see the coding-agent cost model and the measured-cost hub.

FAQ

Can I keep using the OpenAI Python SDK?

Yes. Set base_url to the OpenAI-compatible endpoint and pass a model id from the provider's catalogue. Chat Completions calls, streaming and tools work; OpenAI-only APIs such as Assistants and the Responses API do not.

Is the request/response format identical?

For Chat Completions it is compatible, but individual models differ in tool-calling strictness, JSON-mode support, vision input and tokenizer behaviour. Test your specific features.

Do I need to rewrite prompts?

Usually not, but Chinese models may respond differently to system prompts, formatting instructions and refusal policies. Run your evaluation set before switching production traffic.

How do I compare costs fairly?

Compare cost per successful task, not price per token: include retries, cache hit rates and output token distribution. A cheaper model that needs two attempts is often more expensive.

Can I mix models in one application?

Yes. Use one base URL and key, then choose per task: a cheap model for extraction and a stronger one for reasoning or coding. Keep a fallback model configured.

Try it with a free key

One OpenAI-compatible endpoint for DeepSeek, Qwen, GLM, Kimi, MiniMax and Doubao. Five models are free to call without a credit card.

Get a free API key →