You've been using OpenAI's API. The pricing is climbing. You've heard about cheaper alternatives. But rewriting your entire codebase? That's a non-starter.
Good news: you don't need to rewrite anything. Dozens of world-class LLM providers now offer OpenAI-compatible APIs. You change two lines of code โ the base URL and API key โ and you're running on models that are 80โ97% cheaper.
Total migration time:
Two lines of code. Zero refactoring. Same SDK.
OpenAI's API has become the de facto standard for LLM interactions. But relying on a single provider creates risks:
An OpenAI compatible API solves all of these. You keep the same SDK, same code patterns, same mental model โ but gain access to 38+ models from multiple providers, at dramatically lower costs.
An API is "OpenAI compatible" when it implements the same HTTP endpoints, request format, and response format as OpenAI's API. Specifically:
| Feature | Status |
|---|---|
Chat Completions (/v1/chat/completions) | โ Fully compatible |
| Streaming responses | โ Fully compatible |
| Function calling / Tool use | โ Fully compatible |
| JSON mode (structured output) | โ Fully compatible |
Embeddings (/v1/embeddings) | โ Most providers |
| Standard params (temperature, top_p, max_tokens) | โ Fully compatible |
| OpenAI Python/Node.js SDK | โ Works as-is |
In practice, this means: if your code works with OpenAI, it works with any compatible provider. Period.
Sign up at AI Token and grab your API key. This single key gives you access to 38+ models from DeepSeek, Qwen, GLM, Kimi, MiniMax, Step, and more.
Replace the OpenAI endpoint with the AI Token endpoint. That's it โ everything else stays the same.
- client = OpenAI(api_key="sk-your-openai-key")
+ client = OpenAI(
+ base_url="http://47.237.87.92:3001/v1",
+ api_key="your-ai-token-key"
+ )- model="gpt-4o"
+ model="deepseek-ai/DeepSeek-V4-Flash" # or any of 38+ modelsThat's it. Your existing prompts, streaming logic, function definitions, and error handling all work unchanged.
from openai import OpenAI
# ============================================
# BEFORE: OpenAI
# ============================================
# client = OpenAI(api_key="sk-your-openai-key")
# response = client.chat.completions.create(
# model="gpt-4o",
# messages=[{"role": "user", "content": "Hello!"}]
# )
# ============================================
# AFTER: AI Token (2 lines changed!)
# ============================================
client = OpenAI(
base_url="http://47.237.87.92:3001/v1",
api_key="your-ai-token-key"
)
# DeepSeek V4 Flash โ 97% cheaper than GPT-4o
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
# ============================================
# Streaming works too โ no changes needed!
# ============================================
stream = client.chat.completions.create(
model="qwen/Qwen2.5-72B-Instruct",
messages=[{"role": "user", "content": "Write a poem about code"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
# ============================================
# Function calling works too!
# ============================================
import json
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=tools
)
print(response.choices[0].message.tool_calls)
import OpenAI from 'openai';
// BEFORE: OpenAI
// const client = new OpenAI({ apiKey: 'sk-your-openai-key' });
// AFTER: AI Token โ just change baseURL and apiKey!
const client = new OpenAI({
baseURL: 'http://47.237.87.92:3001/v1',
apiKey: 'your-ai-token-key'
});
// Basic chat completion
const response = await client.chat.completions.create({
model: 'deepseek-ai/DeepSeek-V4-Flash',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain recursion in one paragraph.' }
]
});
console.log(response.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({
model: 'qwen/Qwen2.5-72B-Instruct',
messages: [{ role: 'user', content: 'Write a haiku about APIs' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
# Same format as OpenAI โ just different base URL and model
curl http://47.237.87.92:3001/v1/chat/completions \
-H "Authorization: Bearer your-ai-token-key" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-ai/DeepSeek-V4-Flash",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "What is 2+2?"}
],
"temperature": 0.7,
"max_tokens": 100,
"stream": false
}'
Once connected, you can use any of these models by changing the model parameter:
| Provider | Model Name | Best For | Cost vs GPT-4o |
|---|---|---|---|
| DeepSeek | deepseek-ai/DeepSeek-V4-Flash | General, coding | 97% cheaper |
| DeepSeek | deepseek-ai/DeepSeek-V4-Pro | Complex tasks | 80% cheaper |
| DeepSeek | deepseek-ai/DeepSeek-R1 | Reasoning, math | 78% cheaper |
| Qwen | qwen/Qwen2.5-72B-Instruct | Chinese, long context | 94% cheaper |
| GLM | zhipu/glm-4-flash | Budget, prototyping | FREE |
| Kimi | moonshot/kimi-128k | Document analysis | 92% cheaper |
| MiniMax | minimax/abab6.5-chat | Multimodal, voice | 93% cheaper |
| OpenAI | openai/gpt-4o | Frontier tasks | same price |
With AI Token, you can implement intelligent model routing โ using the cheapest model that's good enough for each task:
from openai import OpenAI
client = OpenAI(
base_url="http://47.237.87.92:3001/v1",
api_key="your-ai-token-key"
)
def smart_complete(messages, task_type="general"):
"""Route to the best model based on task type."""
model_map = {
"general": "deepseek-ai/DeepSeek-V4-Flash", # $0.14/M โ fast & cheap
"chinese": "qwen/Qwen2.5-72B-Instruct", # $0.15/M โ best Chinese
"reasoning": "deepseek-ai/DeepSeek-R1", # $0.55/M โ deep thinking
"long_doc": "moonshot/kimi-128k", # $0.20/M โ 128K context
"free": "zhipu/glm-4-flash", # $0.00 โ completely free
"premium": "openai/gpt-4o", # $2.50/M โ frontier quality
}
model = model_map.get(task_type, model_map["general"])
return client.chat.completions.create(
model=model,
messages=messages,
temperature=0.7
)
# Usage โ just specify the task type!
result = smart_complete(
messages=[{"role": "user", "content": "Summarize this meeting transcript..."}],
task_type="general"
)
# Chinese content โ auto-routed to Qwen
result = smart_complete(
messages=[{"role": "user", "content": "ๅธฎๆ็ฟป่ฏ่ฟๆฎต่ฏๆ่ฑๆ..."}],
task_type="chinese"
)
base_url in your OpenAI client initializationapi_key to your new keyOne line of code. 38+ models. OpenAI-compatible. Zero risk.
Get Your API Key โ Try Before You BuyAn OpenAI compatible API uses the exact same HTTP endpoints, request format, and response format as OpenAI's API. This means the official OpenAI SDK (Python, Node.js, etc.) works without any modifications โ you just change the base URL and API key. It's like having a universal remote control that works with every TV brand.
It takes literally 2 lines of code. Change base_url to the new provider's endpoint and update your api_key. All your existing prompts, streaming logic, function calling, and error handling remain exactly the same. We recommend testing in the free playground first, then updating your production config.
DeepSeek, Qwen, GLM, Kimi, MiniMax, Step, Yi, Baichuan, and 30+ other models all provide OpenAI-compatible endpoints. Through AI Token, all 38+ models work seamlessly with the standard OpenAI SDK โ Python, Node.js, Go, Ruby, etc.
Yes. Streaming (Server-Sent Events), function calling, JSON mode, and all standard parameters work identically. The wire format is the same โ that's what "compatible" means. Some providers may have slight differences in advanced features like logprobs, but core functionality is identical.
Absolutely. With AI Token, you can call different models in different requests using the same client. Use DeepSeek V4 Flash for general tasks, Qwen for Chinese content, Kimi for long documents โ all through the same endpoint with the same API key. You can even implement smart routing to automatically select the best model per request.
Just change the base_url and api_key back to OpenAI's. Since all your code uses the same OpenAI SDK format, there's zero lock-in. You can switch between providers freely โ or use AI Token to access OpenAI models alongside Chinese alternatives through the same endpoint.