API 接口与范例
协议要与所选模型及渠道相符。下方使用完整请求 URL;不要把控制台页面当作接口地址。
| 协议 | 完整端点 |
|---|---|
| Chat Completions | POST /v1/chat/completions |
| Responses | POST /v1/responses |
| Anthropic Messages | POST /v1/messages |
Chat Completions
curl https://tokensclub.top/v1/chat/completions \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_ENABLED_MODEL","messages":[{"role":"user","content":"只回复 OK"}]}' Responses
curl https://tokensclub.top/v1/responses \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_ENABLED_MODEL",
"input": "Hello, TokensClub."
}'图片生成(1K)
GPT 图片模型目前只验收 size=1024x1024(1K)的请求设置,按成功输出张数计费。实际回传尺寸可能不同;需要固定尺寸时请先检查图片。请使用 GPT 分组的 API Key;其他尺寸或品质设置尚未验收。
curl https://tokensclub.top/v1/images/generations -H "Authorization: Bearer $TOKENSCLUB_API_KEY" -H "Content-Type: application/json" -d '{"model":"gpt-image-1","prompt":"A blue circle on white","n":1,"size":"1024x1024"}'全能生图 API
在本站 API 密钥页选择“全能生图”分组。Base URL 为 https://tokensclub.top/v1;文生图使用 POST /v1/images/generations,参考图编辑使用 POST /v1/images/edits。model 必须填写价目表中的完整名称。
必须提供下表中的 size;档位按请求尺寸选择,不按返回像素重新定价。n 为 1–15 的整数,默认 1。仅支持非流式、quality=auto 和 PNG 输出;response_format 可选 url 或 b64_json。其他参数会明确拒绝,不会自动删除或替换。
其他图片模型尺寸表
| 比例 | 1K | 2K | 4K |
|---|---|---|---|
| 1:1 | 1024x1024 | 2048x2048 | 3840x3840 |
| 16:9 | 1280x720 | 2560x1440 | 3840x2160 |
| 9:16 | 720x1280 | 1440x2560 | 2160x3840 |
| 3:2 | 1536x1024 | 3072x2048 | 3840x2560 |
| 2:3 | 1024x1536 | 2048x3072 | 2560x3840 |
| 4:3 | 1344x1008 | 2688x2016 | 3840x2880 |
| 3:4 | 1008x1344 | 2016x2688 | 2880x3840 |
| 5:4 | 1280x1024 | 2560x2048 | 3840x3072 |
| 4:5 | 1024x1280 | 2048x2560 | 3072x3840 |
| 21:9 | 1792x768 | 3136x1344 | 4032x1728 |
实际可选尺寸仍受模型限制:-fb 的 1K 仅支持 1:1、4:3、3:4、2:3、9:16、16:9,2K/4K 仅支持 16:9,也不支持参考图。Lite 仅支持 1K,Firefly 不支持 4K。
curl https://tokensclub.top/v1/images/generations \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-H "Content-Type: application/json" \
--data '{"model": "gpt-image-2", "prompt": "A blue circle on white", "size": "1024x1024", "n": 1, "quality": "auto"}'参考图编辑使用 multipart/form-data;image 或 image[] 放 PNG、JPEG 或 WebP 文件。请遵守表内张数上限,整个请求最多 64 MiB。
curl https://tokensclub.top/v1/images/edits \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-F model=gpt-image-2 \
-F prompt="Use a clean studio background" \
-F size=2048x2048 \
-F n=1 \
-F "image=@/absolute/path/reference.png"gpt-image-2.6
仅支持下表列出的尺寸,按本站尺寸档位及成功张数计费。4K 正方形为 4096×4096;参考图编辑每次最多 5 张。
| 档位 | 比例 | size |
|---|---|---|
| 1K | 1:1 | 1024x1024 |
| 1K | 3:2 | 1536x1024 |
| 1K | 2:3 | 1024x1536 |
| 1K | 3:4 | 1008x1344 |
| 1K | 9:16 | 720x1280 |
| 1K | 16:9 | 1280x720 |
| 2K | 1:1 | 2048x2048 |
| 2K | 16:9 | 2560x1440 |
| 4K | 1:1 | 4096x4096 |
| 4K | 16:9 | 3840x2160 |
curl https://tokensclub.top/v1/images/generations \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-H "Content-Type: application/json" \
--data '{"model": "gpt-image-2.6", "prompt": "A red cube on a white table", "size": "1024x1024", "n": 1, "quality": "auto", "output_format": "png"}'curl https://tokensclub.top/v1/images/edits \
-H "Authorization: Bearer $TOKENSCLUB_API_KEY" \
-F model=gpt-image-2.6 \
-F prompt="make the cube blue" \
-F size=1024x1024 \
-F n=1 \
-F quality=auto \
-F output_format=png \
-F "image=@/absolute/path/reference.png"JavaScript:服务端请求
const response = await fetch("https://tokensclub.top/v1/responses", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TOKENSCLUB_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ model: "YOUR_ENABLED_MODEL", input: "只回复 OK" })
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());串流与重试
需要串流时,按对应协议传入 stream: true,并使用 SSE 解析器处理增量事件。断线或超时后,先核对使用记录;重试可能形成另一笔独立用量。
图片、工具调用、快取及长上下文的支援范围取决于模型和渠道,不能由基本文字成功推断。