Open Source · MIT License · github.com/AAAjczz/chinai-gateway

Chinese AI Models,
One API.

Self-hosted gateway unifying China's top 5 AI providers — DeepSeek, Qwen, GLM, Kimi, ERNIE — behind a single OpenAI-compatible endpoint. 5-minute deploy. Your server. Your keys. Zero platform fees.

chinaigateway.xyz — bash
$ curl -s https://chinaigateway.xyz/v1/chat/completions \
  -H "Authorization: Bearer sk-IxF6Z..." \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Hello"}]}'

{
  "model": "deepseek-v4-pro",
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "Hello! I'm DeepSeek V4 Pro, running through
      Chinai Gateway — an open-source proxy that unifies
      Chinese AI models behind one standard API."
    }
  }],
  "usage": { "prompt_tokens": 8, "completion_tokens": 35 }
}
GitHub Stars
0
Pre-configured Models
0
AI Providers
0
MB RAM Footprint
0
Minute Deploy
Get Started
Three Commands to Production
No signup forms. No cloud dashboards. Just your terminal and 5 minutes.
1

Clone & Configure

Copy the repo, add your API keys to .env. One key or all five — your choice. Leave a provider blank and its models are disabled.

2

Docker Compose Up

Single command boots PostgreSQL 16 + LiteLLM. ~430MB RAM total. Runs on any $5/month VPS alongside your existing services.

3

Call Your API

Use any OpenAI SDK — Python, JS, curl, LangChain, Cursor, AutoGPT. Change one base_url. All 14 models speak the same protocol.

Interactive Demo
Try It Live
DeepSeek V4 Pro & Flash are live on this demo server. Qwen, GLM, Kimi, and ERNIE require your own deployment with your API keys.
Interactive Playground
Demo: DeepSeek only · $0.05 budget
Response
Send a message to see the response here.

💡 Demo key: read-only · $0.05 budget · 10 RPM · DeepSeek V4 Pro & Flash only. Full access: deploy your own (free, MIT, 5 min).

Why Chinai Gateway
OpenRouter's Open-Source Twin — Without the 5.5% Fee
OpenRouter is great. But it's closed-source, your data transits their servers, and they take a cut. Chinai Gateway is the same convenience — self-hosted, MIT licensed, zero platform tax.
🔑

Your Keys Never Leave Your Server

API keys are read from your .env file, injected into LiteLLM at startup, and never logged. No telemetry. No phoning home. No third party sees your credentials, requests, or responses. The MIT license means you can audit every line.

Privacy-firstMIT LicensedZero Telemetry
💰

10–65× Cheaper Than GPT-4o

DeepSeek V4 Pro at ¥3/M tokens ($0.41) vs GPT-4o at $2.50/M. For a typical 1000-request/day app, that's $225/month → $18/month.

🔄

One Endpoint. 14 Models.

Change one field in your request to switch between DeepSeek, Qwen, GLM, Kimi, and ERNIE. Every model speaks OpenAI protocol. No SDK changes. No library updates. No vendor lock-in.

"model": "deepseek-v4-pro""qwen-max""glm-4-plus""kimi-128k""ernie-4.0-turbo"
🖥️

Admin Dashboard

Built-in UI at /ui. Create virtual keys with per-user budgets and rate limits. Track spend per model. No extra tools required.

📦

Runs on a $5 VPS — Fits Alongside Everything Else

~430MB RAM total: PostgreSQL (~80MB) + LiteLLM (~300MB) + Nginx (~50MB). No GPU. This entire demo runs on a $2/month RackNerd VPS alongside Hysteria2 and other services. The infrastructure costs less than lunch.

🔌

Drop-in OpenAI Replacement

Change one base_url in your OpenAI client. Every SDK, every framework, every tool that speaks OpenAI — they all just work.

Real Use Cases
What Can You Build?
Three concrete scenarios. Code included. Not hypotheticals — these patterns are in production today.
Use Case 01

Migrate from OpenAI in 5 Minutes

You're spending $300/month on GPT-4o. Your codebase is built on the OpenAI SDK. The idea of switching providers means rewriting every API call — except it doesn't.
# Before: GPT-4o — $2.50/M input tokens client = OpenAI(api_key="sk-openai-...") # After: DeepSeek V4 Pro — $0.41/M input tokens client = OpenAI( api_key="sk-your-master-key", base_url="http://localhost:4000/v1" # ← only this line changes ) # That's it. Every other line of code stays identical.
✅ Same code. 12.5× cheaper. Zero API format changes.
Use Case 02

Multi-Model Router: Right Model, Right Task

No single model is best at everything. DeepSeek excels at code. Qwen dominates Chinese text. Kimi handles 128K documents. You want to route each request to the optimal model — without managing four different SDKs.
# Route by task type — all through one endpoint def route(task_type): return { "code": "deepseek-v4-pro", # 1M context, agent-ready "chat_cn": "qwen-max", # best Chinese quality "long_doc": "kimi-128k", # 128K document analysis "search": "ernie-4.0-turbo", # Baidu search-enhanced "default": "deepseek-v4-flash", # cheapest + fastest }[task_type] # All models share the same client, same base_url, same API format.
✅ One codebase. Five specialized models. Zero integration overhead.
Use Case 03

Team API Management: Keys, Budgets, Limits

Your team of 5 developers needs API access to DeepSeek. Without a gateway, you share one API key — no per-person budgets, no rate limiting, no way to track who's spending what. One person's runaway loop burns the shared quota.
# Admin UI: http://your-server:4000/ui # Create virtual keys per developer: Alicesk-alice-key $20/month budget, 100 RPM Bobsk-bob-key $10/month budget, 50 RPM Charliesk-charlie-key $5/month budget, read-only models # Each key logs usage independently. # Budget exhausted → auto-blocks. No surprises.
✅ Granular cost control. Accountability per developer. No shared-key disasters.
Under the Hood
Architecture & Security
How data flows through Chinai Gateway — and why it never reaches us.
┌─ Your Infrastructure ──────────────────────────────────────┐
                                                            
  ┌──────────┐     ┌───────────────┐     ┌────────────┐   
  │  Nginx   │ ───▶ │  LiteLLM      │ ───▶ │ DeepSeek   │   
  │  :443    │     │  Proxy :4000  │     │ Qwen       │   
  │  HTTPS   │     │  Docker       │     │ GLM        │   
  └──────────┘     │               │     │ Kimi       │   
                     │  ┌─────────┐  │     │ ERNIE      │   
                     │  │PostgreSQL│  │     └────────────┘   
                     │  │(internal)│  │                        
                     │  └─────────┘  │                        
                     └───────────────┘                        
                                                            
  ▲ .env file (API keys) — never leaves this server      
  ▲ PostgreSQL — internal Docker network, no external port 
  ▲ No telemetry, no phoning home, no analytics           
└────────────────────────────────────────────────────────────┘
🔒

API Keys Stay in .env

Keys are read at container startup, injected as environment variables, and never persisted to disk or logged. PostgreSQL stores virtual key metadata — never provider credentials.

🏠

Database Is Internal-Only

PostgreSQL listens on the internal Docker network. No port exposed to the host. No external access possible. Only LiteLLM can reach it.

📋

MIT — Audit It Yourself

Every line of our code is public. The Docker images are pulled from GitHub Container Registry with SHA256 pins. No black boxes. No trust required.

🚫

Zero Telemetry

Chinai Gateway does not phone home. No usage analytics. No crash reports. No update checks. The demo at chinaigateway.xyz is the only thing we run — and it's optional.

Performance
How Much Overhead Does the Proxy Add?
Measured against direct API calls. The proxy layer adds negligible latency — you're paying for model inference, not routing.
RouteTypical LatencyOverhead
Direct → DeepSeek API~200msbaseline
Your App → Chinai Gateway → DeepSeek~220ms+20ms (1.1×)
Your App → OpenRouter → DeepSeek~250ms+50ms (1.25×)

* Approximate, measured on a $5/month VPS. Streaming first-token latency is typically lower. Actual latency depends on model, prompt length, and network conditions.

Model Catalog
14 Models. 5 Providers. 1 Endpoint.
All first-tier Chinese AI providers, pre-configured. Click column headers to sort.
Model Provider Input / 1M Output / 1M ContextFeatures
deepseek-v4-proDeepSeek¥3¥61,048,576AgentThinkingFunc Call
deepseek-v4-flashDeepSeek¥1¥21,048,576ThinkingBest Value
deepseek-chatDeepSeek (legacy)¥1¥265,536Deprecated Jul 2026
deepseek-reasonerDeepSeek (legacy)¥4¥1665,536Deprecated Jul 2026
qwen-plusAlibaba Qwen¥2¥6131,072ChineseFunc Call
qwen-maxAlibaba Qwen¥20¥6032,768Best CNFlagship
qwen-vl-plusAlibaba Qwen¥2¥632,768VisionImage
glm-4-plusZhipu GLM¥1¥4131,072Func Call128K
glm-4-flashZhipu GLMFreeFree131,072Free TierFast
glm-4v-plusZhipu GLM¥5¥532,768VisionOCR
kimiMoonshot¥12¥128,192Doc Analysis
kimi-128kMoonshot¥60¥60131,072Ultra-Long128K
ernie-4.0-turboBaidu ERNIE¥4¥128,192SearchEnterprise
ernie-speedBaidu ERNIEFreeFree131,072Free Tier128K
Cost Comparison
What Does One Request Cost?
Same 50-word question, 200-word answer. ~50 input + ~100 output tokens. USD at ¥7.3 = $1.
OpenAI
GPT-4o
$0.0075
per request
baseline
Anthropic
Claude Opus 4
$0.0525
per request
7× GPT-4o
DeepSeek
V4 Pro · via Chinai Gateway
$0.0006
per request
12.5× cheaper
DeepSeek
V4 Flash · via Chinai Gateway
$0.0002
per request
37.5× cheaper

📊 Monthly Cost Projection: 1,000 Requests / Day

GPT-4o (OpenAI)$225 / month
Claude Opus 4 (Anthropic)$1,575 / month
DeepSeek V4 Pro (via Chinai Gateway)$18 / month
DeepSeek V4 Flash (via Chinai Gateway)$6 / month
Calculated at 50 input + 100 output tokens per request, 30,000 requests/month. DeepSeek at ¥7.3/USD. Actual costs vary by prompt length and tokenizer.
Landscape
How We Compare
The AI gateway space has options. Here's where Chinai Gateway fits — and where it doesn't.
Feature
Chinai Gateway
OpenRouter
One API
Direct API
Source
Open (MIT)
Closed
Open (MIT)
N/A
Hosting
Self-hosted
Managed cloud
Self-hosted
Provider cloud
Data Privacy
Full — never leaves
Transits OpenRouter
Full
Through provider
Documentation
EN + 中文
EN only
中文 only
中文 only
Pre-configured
14 models, 5 providers
Manual per model
Manual config
N/A
Deploy Time
< 5 min
None (hosted)
~15 min
~30 min/provider
Platform Fee
$0
+5.5%
$0
$0
Virtual Keys
Budgets, limits, expiry
Basic limits
Basic
Admin Dashboard
Built-in
Built-in
Built-in
Per provider
Target
Overseas devs → Chinese AI
Global → any model
CN devs → foreign AI
Direct consumers
Integration
Same API. Any Language.
OpenAI protocol means every SDK works natively. No new libraries. No vendor lock-in.
# Replace YOUR_KEY with your master key from .env
curl -X POST http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ]
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_MASTER_KEY",
    base_url="http://localhost:4000/v1"
)

# Streaming response with reasoning_content (DeepSeek V4 Pro)
stream = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ],
    stream=True,
    temperature=0.7
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
import OpenAI from 'openai';

const client = new OpenAI({
    apiKey: 'YOUR_MASTER_KEY',
    baseURL: 'http://localhost:4000/v1',
});

const response = await client.chat.completions.create({
    model: 'deepseek-v4-pro',
    messages: [
        { role: 'system', content: 'You are a helpful assistant.' },
        { role: 'user', content: 'Write a haiku about recursion.' }
    ],
});

console.log(response.choices[0].message.content);
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    api_key="YOUR_MASTER_KEY",
    base_url="http://localhost:4000/v1",
    model="deepseek-v4-pro",
    temperature=0.7,
)

response = llm.invoke("What is the capital of France?")
print(response.content)
Questions
FAQ
If your question isn't here, open an issue on GitHub.

Neither. Chinai Gateway is free, open-source software (MIT) that you deploy on your own server. We don't run a hosted version. We don't charge anything. We don't see your data, keys, or traffic. The demo at chinaigateway.xyz is just that — a demo — running on a $2/month VPS with a read-only DeepSeek key capped at $0.05.

OpenRouter is a managed cloud service — your requests go through their infrastructure, and they charge 5.5% on top of model pricing. Chinai Gateway is self-hosted: you run it on your VPS, your data stays local, zero platform fees. We're pre-configured specifically for Chinese AI models with bilingual documentation. Think of OpenRouter as a service you rent; Chinai Gateway as infrastructure you own.

For DeepSeek, you register at platform.deepseek.com — the interface has an English option. For Qwen, GLM, Kimi, and ERNIE, the registration pages are primarily in Chinese, but the process is standard (phone/email verification, API key generation). Our docs/models.md links to each provider's key page. Once you have keys, everything else is in English.

Yes. Edit config.yaml and add any provider from LiteLLM's 100+ supported backends. Chinai Gateway is a starting point — not a walled garden. You can route some requests to DeepSeek (cheap) and others to Claude (quality), all through the same endpoint.

~430MB RAM total: PostgreSQL (~80MB) + LiteLLM (~300MB) + Nginx (~50MB). A $5/month VPS with 1GB RAM is more than enough. No GPU required. The demo runs on a $2/month RackNerd VPS alongside Hysteria2 and other services.

LiteLLM (the engine) is production-tested by thousands of teams. Chinai Gateway adds pre-configuration, docs, and deploy tooling. For critical workloads: add Nginx + HTTPS (our deployment.md covers this), set up monitoring, and pin Docker image SHAs. The MIT license means you can harden it to your own standards.

Docker ensures PostgreSQL + LiteLLM are isolated, versioned, and reproducible across any Linux server. It also keeps the host clean — no Python dependencies to manage. If you prefer bare metal, you can run LiteLLM with pip install litellm and connect to any PostgreSQL instance. But Docker is the path of least friction — and that's the point.

Chinai Gateway was built by a university student in China who wanted overseas developers to access Chinese AI models without the friction of registering on five different platforms and adapting five different API formats. It's MIT licensed — free forever, no strings attached. The project is a portfolio piece and a public good, not a startup.

Deploy in 5 Minutes. Save 90% on AI Costs.

One docker compose up -d. Five AI providers. Fourteen models. Your server, your keys, MIT license. Free forever.