DEV Community

ChinaWHAPI Team
ChinaWHAPI Team

Posted on

OpenAI-Compatible Chinese LLM API: Complete Integration Guide 2026

Looking for a reliable way to access Chinese AI models with an OpenAI-compatible API? This comprehensive guide covers everything you need to know about using OpenAI-compatible Chinese LLM APIs through ChinaWHAPI gateway in 2026.

What is OpenAI-Compatible Chinese LLM API?

Chinese AI providers like DeepSeek, Qwen (Alibaba), GLM (Zhipu), and others now offer large language models that can be accessed via OpenAI-compatible APIs. This means you can use the same OpenAI SDK to interact with these models - just change the base URL and API key.

However, accessing these APIs directly from outside China can be challenging due to:

  • Network connectivity issues
  • High latency
  • Payment restrictions (requires Chinese payment methods)
  • Account verification requirements

Why Use ChinaWHAPI for OpenAI-Compatible Access?

ChinaWHAPI provides a unified gateway to access 20+ Chinese AI models with full OpenAI compatibility:

  • Single Endpoint: One API key for DeepSeek, Qwen, GLM, Yi, and more
  • 100% OpenAI-Compatible: Works with existing OpenAI client libraries - zero code changes
  • Global CDN: Stable, low-latency connection worldwide
  • Transparent Pricing: Pay-as-you-go with clear billing
  • Easy Integration: Drop-in replacement for OpenAI endpoint

Getting Started with ChinaWHAPI

Step 1: Sign Up and Get API Key

Visit ChinaWHAPI to create your account and obtain your API key. You'll receive free trial credits to test the service.

Step 2: Configure Your Endpoint

Replace your existing OpenAI endpoint with ChinaWHAPI's endpoint:

Base URL: https://api.chinawhapi.com/v1
API Key: Your ChinaWHAPI API key
Enter fullscreen mode Exit fullscreen mode

Step 3: Start Using Chinese LLM Models

Here's how to use Chinese models with Python:

from openai import OpenAI

client = OpenAI(
    api_key="your_chinawhapi_api_key",
    base_url="https://api.chinawhapi.com/v1"
)

# Use DeepSeek V3
response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

For Node.js developers:

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'your_chinawhapi_api_key',
  baseURL: 'https://api.chinawhapi.com/v1'
});

const response = await client.chat.completions.create({
  model: 'qwen-plus',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Hello!' }
  ]
});

console.log(response.choices[0].message.content);
Enter fullscreen mode Exit fullscreen mode

Available Chinese LLM Models

ChinaWHAPI provides access to all major Chinese AI models:

Provider Model Description Input Price Output Price
DeepSeek deepseek-chat DeepSeek V3 for general tasks $0.27 / 1M tokens $1.10 / 1M tokens
DeepSeek deepseek-reasoner DeepSeek R1 for reasoning $0.55 / 1M tokens $2.19 / 1M tokens
Qwen qwen-plus Qwen 2.5 for general tasks Contact for pricing Contact for pricing
Qwen qwen-max Most powerful Qwen model Contact for pricing Contact for pricing
GLM glm-4 Zhipu GLM-4 model Contact for pricing Contact for pricing

Advanced Usage Examples

Streaming Responses

stream = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
Enter fullscreen mode Exit fullscreen mode

Function Calling

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name"}
                }
            }
        }
    }
]

response = client.chat.completions.create(
    model="qwen-plus",
    messages=[{"role": "user", "content": "What's the weather in Beijing?"}],
    tools=tools
)
Enter fullscreen mode Exit fullscreen mode

Best Practices

  1. Error Handling: Implement retry logic for network errors
  2. Rate Limiting: Monitor your usage to avoid hitting rate limits
  3. Token Management: Keep track of token consumption for cost optimization
  4. Caching: Cache frequent responses to reduce API calls

Troubleshooting Common

Top comments (0)