Tài liệu API

Quyền truy cập hợp nhất vào các model AI hàng đầu thế giới. API tương thích OpenAI — một khóa cho tất cả model.

URL gốc API

https://tokenhub.store/api/v1

Tất cả yêu cầu API đều sử dụng URL gốc này. Tương thích hoàn toàn với OpenAI SDKs.

Bắt đầu nhanh

Thiết lập trong vài phút

  1. Tạo tài khoản và đăng nhập vào Dashboard của bạn
  2. Đi tới API Keys và tạo một API key mới
  3. Truy cập Thanh toán để nạp Credits vào tài khoản của bạn
  4. Bắt đầu gọi API với bất kỳ model được hỗ trợ nào

Model được hỗ trợ

Nhấp vào một nhà cung cấp để xem các model khả dụng và ví dụ mã nguồn.

OpenAI

6 model

Công ty nghiên cứu AI hàng đầu, nhà tạo ra dòng GPT. Nổi tiếng với các model ngôn ngữ tiên tiến, khả năng suy luận và lập trình xuất sắc.

Anthropic

6 model

Công ty an toàn AI nổi tiếng với các model Claude. Xuất sắc trong hội thoại tinh tế, code và suy luận phức tạp với các tính năng an toàn mạnh mẽ.

Google

5 model

Gia đình Gemini của Google mang đến khả năng đa phương thức tiên tiến với cửa sổ ngữ cảnh hàng đầu ngành lên tới 2M tokens.

xAI

3 model

Công ty AI của Elon Musk. Các model Grok nổi tiếng với kiến thức thời gian thực, phản hồi dí dỏm và hỗ trợ lập trình xuất sắc.

Alibaba (Qwen)

3 model

Dòng Qwen của Alibaba cung cấp các model đa ngôn ngữ mạnh mẽ, với hiệu năng tốt trong cả tác vụ tiếng Anh và tiếng Trung.

Zhipu AI (GLM)

3 model

Dòng GLM của Zhipu AI. Các model song ngữ Trung-Anh tiên tiến với cửa sổ ngữ cảnh lên tới 200K.

MiniMax

2 model

Dòng M2 của MiniMax. Ngữ cảnh siêu dài 205K với năng lực đa ngôn ngữ mạnh mẽ.

Xiaomi (MiMo)

2 model

Các model MiMo V2 của Xiaomi. Cửa sổ ngữ cảnh lớn lên tới 1M tokens.

Alibaba (Qwen3)

3 model

Dòng Qwen3 của Alibaba. Các model MoE quy mô lớn với chuyên môn về thị giác-ngôn ngữ và lập trình.

Moonshot AI (Kimi)

3 model

Dòng Kimi K2 của Moonshot AI. Khả năng suy luận mạnh mẽ với cửa sổ ngữ cảnh mở rộng.

DeepSeek

6 model

Các model mới nhất của DeepSeek. Chi phí rất tối ưu với năng lực suy luận và lập trình mạnh mẽ.

ByteDance (Seedance)

2 model

Các model tạo video Seedance của ByteDance. Chuyển văn bản thành video chất lượng điện ảnh, ảnh thành video, và chỉnh sửa video đa phương thức với hỗ trợ âm thanh.

ByteDance (Seedream)

3 model

Các model tạo ảnh Seedream của ByteDance. Văn bản thành ảnh chất lượng cao với phong cách chân thực và nghệ thuật.

Kwaivgi (Kling)

2 model

Các model tạo video Kling của Kwaivgi. Tạo video chất lượng cao từ văn bản và ảnh với chế độ std/pro. Thời lượng 3–15s. std: $0.168/s, pro: $0.224/s (không có âm thanh).

Các API Endpoints

POST /chat/completions

Tạo một chat completion với hỗ trợ stream

Headers

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

Request Body

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

Tạo video từ prompt văn bản hoặc ảnh (Seedance & Wan 2.2 models)

Headers

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

Request Body

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

Request Body (mảng 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"
}

Tham số

content (tùy chọn): Mảng tài sản media. Mỗi mục có:

  • type: "image_url"
  • image_url.url: URL của hình ảnh
  • role: <firstFrame/> (tối đa 1), <lastFrame/> (tối đa 1), <refImage/>, <refVideo/>, <refAudio/>

GET /videos/generations/{id}

Kiểm tra trạng thái của một tác vụ tạo video

Headers

headers
Authorization: Bearer th-your-api-key

Phản hồi

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

Tạo hình ảnh từ prompt văn bản (Seedream models)

Headers

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

Request Body

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

GET /models

Liệt kê tất cả model khả dụng

Ví dụ mã

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);

Ví dụ Streaming (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="")

Cần trợ giúp?

Liên hệ với chúng tôi: support@tokenhub.store