Python examples for building AI applications with the PowerTokens unified AI API.
Unified API for Chinese AI models — no Chinese account required. OpenAI-compatible.
Get started · Docs · Models
| Example | Model | Path |
|---|---|---|
| MiniMax chat | MiniMax-M3 |
chat/minimax_m3.py |
| Qwen chat | qwen3-max |
chat/qwen3_max.py |
| GLM chat | glm-5.2 |
chat/glm_5_2.py |
- Python 3.9+
- A PowerTokens API key
- The OpenAI Python SDK
pip install openaiBase URL for OpenAI-compatible SDKs: https://api.powertokens.ai/v1
export POWERTOKENS_API_KEY=your_key
python chat/minimax_m3.py
# or: python chat/qwen3_max.py
# or: python chat/glm_5_2.pyimport os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["POWERTOKENS_API_KEY"],
base_url="https://api.powertokens.ai/v1",
)
resp = client.chat.completions.create(
model="MiniMax-M3",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Describe Paris in one sentence."},
],
temperature=0.3,
)
print(resp.choices[0].message.content)Create an API key in the dashboard.
Use PowerTokens as an OpenAI-compatible gateway: set base_url to https://api.powertokens.ai/v1, use your PowerTokens API key, and pick a Qwen model id from the catalog (for example qwen3-max). You do not need a mainland China phone / Alibaba account.
- Code:
chat/qwen3_max.py - Docs: Quickstart
- Model page: Models
https://api.powertokens.ai/v1
Example model ids (always confirm in the live catalog):
- GLM:
glm-5.2 - MiniMax:
MiniMax-M3 - DeepSeek:
deepseek-v3-2-251201
client = OpenAI(
api_key=os.environ["POWERTOKENS_API_KEY"],
base_url="https://api.powertokens.ai/v1",
)
resp = client.chat.completions.create(
model="deepseek-v3-2-251201",
messages=[{"role": "user", "content": "Hello"}],
)- Docs: API key and model call
- Protocols: Text model protocols
Both can be OpenAI-compatible gateways. PowerTokens focuses on China-origin model families (Qwen, GLM, MiniMax, DeepSeek, Seed, video stacks) with no Chinese mainland account required and one unified key. Use the model catalog for current ids and pricing; see also awesome-chinese-model-apis for a neutral gateway comparison.
Run pip install openai, create the client with your PowerTokens API key and base_url="https://api.powertokens.ai/v1", then pass model="deepseek-v3-2-251201" to chat.completions.create. The code is the same as chat/qwen3_max.py with only the model id changed.
No. One PowerTokens API key works for every model in the catalog, with no per-model binding, so switching between Qwen, GLM, MiniMax and DeepSeek V3.2 only means changing the model string (create a key).
Yes. Besides OpenAI Chat Completions (/v1/chat/completions), PowerTokens serves the Anthropic Messages format (/v1/messages) used by Claude Code and the OpenAI Responses format (/v1/responses) used by Codex; GLM models are not available on the Responses path (protocol guide). The docs have setup guides for Claude Code, opencode, Kilo Code, Hermes Agent and OpenClaw.
Add Credits on the Billing page with a credit card or PayPal; no Chinese bank account or payment app is needed. See the quickstart.
- One API: video, image, audio, and LLM model families
- OpenAI-compatible: reuse familiar OpenAI SDK patterns
- No Chinese mainland account required
- Website: powertokens.ai
- Documentation: docs.powertokens.ai
- Model catalog: Models
- API keys: API keys
- Discord: https://discord.gg/JtgtRdhJVS
Start building — powertokens.ai. New-user bonus Credits are offered only while a promotion is running; otherwise add Credits on the Billing page.
Maintained by @uselesssoso for PowerTokens.