# Python 接入(兼容OpenAI格式)
from openai import OpenAI
client = OpenAI(
api_key="sk-你的密钥",
base_url="https://api.tokenall.net.cn/v1"
)
# 文生图
response = client.images.generate(
model="sdxl-text-to-image",
prompt="一只可爱的橘猫,赛博朋克风格",
n=1,
size="1024x1024"
)
print(response.data[0].url) # 图片URL
# curl 方式
curl https://api.tokenall.net.cn/v1/images/generations \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "sdxl-text-to-image",
"prompt": "一只可爱的橘猫,赛博朋克风格",
"n": 1,
"size": "1024x1024"
}'
# 1. 注册获取API Key(注册送5元)
# 访问 https://api.tokenall.net.cn
# 2. 调用模型(兼容OpenAI格式)
curl https://api.tokenall.net.cn/v1/chat/completions \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2-7b-instruct",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 100
}'
# 3. Python 接入
from openai import OpenAI
client = OpenAI(
api_key="sk-你的密钥",
base_url="https://api.tokenall.net.cn/v1"
)
response = client.chat.completions.create(
model="qwen2-7b-instruct",
messages=[{"role": "user", "content": "你好"}]
)
print(response.choices[0].message.content)
首Token延迟 < 2秒,与官方API体验一致
国内合规服务,数据不出境,模型本地+国内云运行
Qwen2全系列、DeepSeek全系列、通义千问Max,持续增加中
完全兼容,只需改 base_url 即可无缝切换