OpenAI Compatible Interface Guide
How ChinaWHAPI achieves OpenAI SDK compatibility and how to call Chinese LLMs with existing tools.
Compatibility Principle
ChinaWHAPI's /v1/chat/completions endpoint accepts the exact same request format and fields as the OpenAI API, including messages, model, temperature, max_tokens, stream, etc.
SDK Integration
Simply change the baseURL to ChinaWHAPI's address and pass your API Key to use any OpenAI-compatible SDK to call Chinese models.
Python Example
from openai import OpenAI
client = OpenAI(
api_key="{your_api_key}",
base_url="https://chinawhapi.com/v1"
)
response = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "What is RAG"}]
)
print(response.choices[0].message.content)Node.js Example
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "{your_api_key}",
baseURL: "https://chinawhapi.com/v1",
});
const response = await client.chat.completions.create({
model: "qwen3.6-plus",
messages: [{ role: "user", content: "Write me a piece of code" }],
});LangChain Integration
Use ChatOpenAI in LangChain and set openai_api_base to ChinaWHAPI's address.
Compatible Tools
Cursor, Jan, Cherry Studio, Postman, curl, Python openai package, Node.js openai package, LangChain, LlamaIndex, Dify, and all other tools that support custom base URL.
Notes
Some model parameters may not be supported by upstream (e.g., system_fingerprint for deepseek-r1). ChinaWHAPI will automatically filter incompatible parameters and return the actual upstream response.