API 文档

统一访问世界级 AI model。OpenAI-compatible API — 一个 key 适用于所有 model。

API 基础 URL

https://tokenhub.store/api/v1

所有 API 请求都使用此基础 URL。与 OpenAI SDKs 完全兼容。

快速上手

几分钟即可开始

  1. 创建账号 并登录到您的控制台
  2. 前往 API Keys 并创建一个新的 API Key
  3. 访问 计费 为您的账户充值 Credits
  4. 开始使用任意受支持的 model 发起 API 调用

支持的 Models

点击某个提供商以查看可用 model 和代码示例。

OpenAI

6 个 model

领先的 AI 研究公司,GPT 系列的创造者。以最先进的语言 model 闻名,具备卓越的推理和编程能力。

Anthropic

6 个 model

以 Claude models 闻名的 AI 安全公司。在细腻对话、代码和复杂推理方面表现出色,并具备强大的安全特性。

Google

5 个 model

Google 的 Gemini 系列提供前沿的多模态能力,支持业界领先的上下文窗口,最高可达 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

小米的 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 视频生成模型。支持电影级 text-to-video、image-to-video 以及带音频支持的多模态视频编辑。

ByteDance (Seedream)

3 个 model

ByteDance 的 Seedream 图像生成模型。高质量 text-to-image,支持写实和艺术风格。

Kwaivgi (Kling)

2 个 model

Kwaivgi 的 Kling 视频生成模型。支持高质量 text-to-video 和 image-to-video,提供 std/pro 模式。时长 3–15 秒。std:$0.168/s,pro:$0.224/s(无音频)。

API 端点

POST /chat/completions

创建支持流式传输的聊天补全

请求头

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}

轮询视频生成任务的状态

请求头

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