If your code already talks to the OpenAI SDK, you can reach every major Chinese model without rewriting anything. The trick is an OpenAI-compatible gateway: the request shape stays the same, and you just change the base URL and the model name. Here are the real patterns.
Setup
Create a key on Turiloop, then point any OpenAI SDK at the gateway:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TURILOOP_API_KEY"],
base_url="https://api.turiloop.com/v1",
)That's the whole integration. Everything below uses this one client.
The models you can call
All reachable with the same key. Switch by changing the model field:
- glm-5.2: the current #1 open-weight model (deep dive), with glm-5.1 as the cheaper everyday tier.
- deepseek-v4-pro / deepseek-v4-flash: flagship reasoning and coding, plus the ultra-cheap fast tier.
- kimi-k2.6 / kimi-k2.5: Moonshot's long-context agents.
- minimax-m2.5: cost-efficient general use.
- claude-opus-4-8 / claude-sonnet-4-6: the closed frontier, same key.
Switching models is one line
def ask(model: str, prompt: str) -> str:
r = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
)
return r.choices[0].message.content
print(ask("deepseek-v4-flash", "Classify sentiment: 'shipping was slow'"))
print(ask("deepseek-v4-pro", "Write a binary search in Rust with tests"))Streaming
The gateway streams just like OpenAI. Set stream=True and iterate the deltas:
stream = client.chat.completions.create(
model="kimi-k2.6",
messages=[{"role": "user", "content": "Explain CAP theorem."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)Smart routing: cheap by default, escalate when needed
The biggest cost win is routing the bulk of your traffic to a cheap model and only escalating the hard prompts. The API is uniform, so routing is trivial:
def smart_ask(prompt: str, hard: bool = False) -> str:
model = "deepseek-v4-pro" if hard else "deepseek-v4-flash"
return ask(model, prompt)V4-Flash costs a fraction of a cent per thousand tokens, and V4-Pro stays far below closed-model rates. Sending 90% of traffic to Flash and 10% to Pro can cut your bill by an order of magnitude versus running everything on a frontier model.
Listing models programmatically
curl https://api.turiloop.com/v1/models \
-H "Authorization: Bearer $TURILOOP_API_KEY"Node, too
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TURILOOP_API_KEY,
baseURL: "https://api.turiloop.com/v1",
});
const r = await client.chat.completions.create({
model: "glm-5.2",
messages: [{ role: "user", content: "Hello" }],
});
const reply = r.choices[0].message.content; // the model's answerThat's it
One key, one base URL, OpenAI-compatible. GLM-5.2, DeepSeek V4, Kimi K2.6, MiniMax and Claude, paid with an international card, billed pay-as-you-go. Start on Turiloop.