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 解析器處理增量事件。斷線或超時後,先核對使用記錄;重試可能形成另一筆獨立用量。
圖片、工具調用、快取及長上下文的支援範圍取決於模型和渠道,不能由基本文字成功推斷。