API 文件

統一存取世界級 AI model。OpenAI-compatible API — 一個 key 支援所有 model。

API Base URL

https://tokenhub.store/api/v1

所有 API 請求都使用此 base URL。與 OpenAI SDKs 完全相容。

快速開始

幾分鐘內上手

  1. 建立帳戶 並登入您的 Dashboard
  2. 前往 API Keys 並建立新的 API key
  3. 造訪 帳單 為您的帳戶加值 Credits
  4. 開始使用任何支援的 model 發送 API 呼叫

支援的 Models

點選供應商即可查看可用 models 與程式碼範例。

OpenAI

6 個 model

領先的 AI 研究公司,GPT 系列的創造者。以最先進的語言 model 著稱,具備卓越的推理與程式設計能力。

Anthropic

6 個 model

以 Claude models 聞名的 AI 安全公司。擅長細膩對話、程式碼與複雜推理,並具備強大的安全特性。

Google

5 個 model

Google 的 Gemini 系列提供前沿的多模態能力,context window 領先業界,最高可達 2M tokens。

xAI

3 個 model

Elon Musk 的 AI 公司。Grok models 以即時知識、機智回應與優秀的程式設計輔助聞名。

Alibaba (Qwen)

3 個 model

Alibaba 的 Qwen 系列提供強大的多語言模型,在英文與中文任務上皆有出色表現。

Zhipu AI (GLM)

3 個 model

Zhipu AI 的 GLM 系列。先進的中英雙語模型,支援最高 200K 上下文視窗。

MiniMax

2 個 model

MiniMax 的 M2 系列。超長 205K 上下文,具備強大的多語言能力。

Xiaomi (MiMo)

2 個 model

Xiaomi 的 MiMo V2 模型。支援高達 1M tokens 的大型上下文視窗。

Alibaba (Qwen3)

3 個 model

Alibaba 的 Qwen3 系列。大型 MoE 模型,具備視覺語言與程式碼專長。

Moonshot AI (Kimi)

3 個 model

Moonshot AI 的 Kimi K2 系列。具備強大的推理能力與延展上下文視窗。

DeepSeek

6 個 model

DeepSeek 的最新模型。高性價比,且具備強大的推理與程式碼能力。

ByteDance (Seedance)

2 個 model

ByteDance 的 Seedance 影片生成模型。支援電影級文字轉影片、圖片轉影片,以及具備音訊支援的多模態影片編輯。

ByteDance (Seedream)

3 個 model

ByteDance 的 Seedream 圖像生成模型。高品質文字轉圖像,支援寫實與藝術風格。

Kwaivgi (Kling)

2 個 model

Kwaivgi 的 Kling 影片生成模型。高品質文字轉影片與圖片轉影片,支援 std/pro 模式。時長 3–15s。std: $0.168/s, pro: $0.224/s(不含音訊)。

API 端點

POST /chat/completions

建立支援串流的 chat completion

標頭

headers
Authorization: Bearer th-your-api-key
Content-Type: application/json

請求主體

json
{
  "model": "openai/gpt-4.1",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000,
  "stream": false
}

POST /videos/generations

根據文字或圖片提示生成影片(Seedance 與 Wan 2.2 models)

標頭

headers
Authorization: Bearer th-your-api-key
Content-Type: application/json

請求主體

json
{
  "model": "bytedance/doubao-seedance-2.0",
  "prompt": "A golden retriever running on a sunny beach",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}

請求主體(content 陣列 — first_frame 與 last_frame)

json
{
  "model": "bytedance/doubao-seedance-2.0",
  "prompt": "Hand picks a fresh apple from the tree, the scene smoothly transitions to a hand holding an apple smoothie drink, cinematic lighting in an orchard",
  "content": [
    {
      "type": "image_url",
      "image_url": { "url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic1.jpg" },
      "role": "first_frame"
    },
    {
      "type": "image_url",
      "image_url": { "url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic2.jpg" },
      "role": "last_frame"
    }
  ],
  "duration": 5,
  "resolution": "720p"
}

參數

content(選填):媒體資產陣列。每個項目包含:

  • type:"image_url"
  • image_url.url:圖片的 URL
  • role:<firstFrame/>(最多 1)、<lastFrame/>(最多 1)、<refImage/>、<refVideo/>、<refAudio/>

GET /videos/generations/{id}

輪詢 video 生成任務的狀態

標頭

headers
Authorization: Bearer th-your-api-key

回應

json
{
  "id": "tsk-xxx",
  "object": "video.generation.task",
  "model": "bytedance/doubao-seedance-2.0",
  "status": "succeeded",  // "queued" | "running" | "succeeded" | "failed"
  "data": [
    {
      "video_url": "https://..."
    }
  ]
}

POST /images/generations

根據文字提示生成圖片(Seedream models)

標頭

headers
Authorization: Bearer th-your-api-key
Content-Type: application/json

請求內容

json
{
  "model": "bytedance/doubao-seedream-5.0",
  "prompt": "A serene mountain landscape at sunset",
  "n": 1,
  "size": "2048x2048"
}

GET /models

列出所有可用的 model

程式碼範例

cURL

bash
curl https://tokenhub.store/api/v1/chat/completions \
  -H "Authorization: Bearer th-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Python(OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    api_key="th-your-api-key",
    base_url="https://tokenhub.store/api/v1"
)

# Use any supported model
response = client.chat.completions.create(
    model="openai/gpt-5.4",  # Or any other model
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)

JavaScript / TypeScript

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'th-your-api-key',
  baseURL: 'https://tokenhub.store/api/v1',
});

// Use any supported model
const response = await client.chat.completions.create({
  model: 'anthropic/claude-sonnet-4-6',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);

串流範例(Python)

python
from openai import OpenAI

client = OpenAI(
    api_key="th-your-api-key",
    base_url="https://tokenhub.store/api/v1"
)

stream = client.chat.completions.create(
    model="google/gemini-2.5-pro",
    messages=[{"role": "user", "content": "Write a short story."}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

需要幫助嗎?

聯絡我們: support@tokenhub.store