API ドキュメント

世界最高水準のAI modelへの統一アクセス。OpenAI-compatible API — すべてのmodelに1つのキーで対応します。

API ベース URL

https://tokenhub.store/api/v1

すべてのAPIリクエストはこのBase URLを使用します。OpenAI SDKsと完全互換です。

クイックスタート

数分で開始

  1. アカウントを作成し Dashboardにログインします
  2. へ移動し、 API Keys で新しいAPI keyを作成します
  3. へアクセスし、 請求 でアカウントにCreditsを追加します
  4. 対応している任意のmodelでAPI呼び出しを開始します

対応モデル

プロバイダーをクリックすると、利用可能なmodelとコード例を表示できます。

OpenAI

10モデル

GPTシリーズを生み出した、先進的なAI研究企業です。最先端の言語modelと、優れた推論・コーディング能力で知られています。

Anthropic

8モデル

Claudeモデルで知られるAI安全性企業です。強力な安全機能を備え、ニュアンスのある会話、コード、複雑な推論に優れています。

Google

9モデル

GoogleのGeminiファミリーは、最先端のマルチモーダル機能と、最大2M tokensの業界最高水準のコンテキストウィンドウを提供します。

xAI

3モデル

Elon MuskのAI企業です。Grokモデルは、リアルタイムの知識、機知に富んだ応答、優れたコーディング支援で知られています。

Alibaba (Qwen)

3モデル

AlibabaのQwenシリーズは、英語と中国語のタスクの両方で高い性能を発揮する強力な多言語モデルを提供します。

Zhipu AI (GLM)

3モデル

Zhipu AIのGLMシリーズ。最大200Kコンテキストウィンドウを備えた高度な中国語・英語バイリンガルモデルです。

MiniMax

2モデル

MiniMaxのM2シリーズ。強力な多言語機能を備えた205Kの超長コンテキストです。

Xiaomi (MiMo)

2モデル

XiaomiのMiMo V2モデル。最大1M Tokensまで対応する大規模コンテキストウィンドウです。

Alibaba (Qwen3)

3モデル

AlibabaのQwen3シリーズ。Vision-Languageとコーディングに特化した大規模なMoEモデルです。

Moonshot AI (Kimi)

2モデル

Moonshot AIのKimi K2シリーズ。拡張コンテキストウィンドウと強力な推論能力を備えています。

DeepSeek

6モデル

DeepSeekの最新モデル。強力な推論とコーディング性能を備え、非常にコスト効率に優れています。

ByteDance (Seedance)

2モデル

ByteDanceのSeedance動画生成モデル。音声対応の、映画品質のtext-to-video、image-to-video、マルチモーダル動画編集を提供します。

ByteDance (Seedream)

2モデル

ByteDanceのSeedream画像生成モデル。写実的なスタイルと芸術的なスタイルに対応した高品質なtext-to-imageです。

Kwaivgi (Kling)

2モデル

KwaivgiのKling動画生成モデル。std/proモードに対応した高品質なtext-to-videoとimage-to-videoです。再生時間は3〜15秒。std: $0.168/s、pro: $0.224/s(音声なし)。

Gemini API

Gemini 3.5–3.8 Flash and Gemini 4 Argon use /chat/completions. For Argon, use model ID google/gemini-4-argon. GET /models lists published models. For an unlisted model configured by your account administrator, use the exact model ID they provide with the same endpoint.

curl "https://tokenhub.store/api/v1/chat/completions" \
  -H "Authorization: Bearer th-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.8-flash",
    "messages": [{"role": "user", "content": "Hello"}],
    "reasoning_effort": "low",
    "max_tokens": 1024,
    "stream": true
  }'

Supports streaming, system instructions, function calling, and base64 image data URLs. reasoning_effort accepts low, medium, or high; max_tokens includes thinking tokens.

For multi-turn tools, keep the complete assistant message, including tool_calls.extra_content or content_blocks, so thought signatures are preserved. Native Gemini endpoints are not exposed by TokenHub.

Gemini Flash and Argon output usage includes thinking tokens. Cached input is counted at the configured cache-read rate when available. See the model catalog for current prices; confirm rates for unlisted models with your account administrator.

Responses API のストリーミングと課金

POST /v1/responses では response.completed が応答の完了を示します。このイベントの受信後に接続を閉じても、成功したリクエストはキャンセル扱いになりません。

ゼロを含む上流のトークン数を推定値より優先します。値がない場合のみ推定します。完了前にキャンセルしても、処理済みトークンは課金対象になる場合があります。

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 /responses

OpenAI Responses のネイティブリクエストを JSON / SSE のまま転送

ヘッダー

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

リクエストボディ

json
{
  "model": "openai/gpt-5.6-terra",
  "input": "Explain why the sky is blue in one sentence.",
  "reasoning": { "effort": "medium" },
  "max_output_tokens": 256,
  "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 を一覧表示します

公開中のモデルと最新料金はモデル一覧と料金ページをご覧ください。ページは自動更新されます。

Account management API

Generate an access token in Settings → Account information. Send Authorization: Bearer YOUR_ACCESS_TOKEN and TokenHub-User: YOUR_USER_ID. New-Api-User is also accepted; if both user headers are supplied, they must match. Open settings

Access tokens manage your account. Continue using th- API keys for model requests.

HTTPEndpointDescription
GET/api/balanceAccount credit balance (1 credit = 1 USD)
GET / POST/api/keysList keys or create a key
GET / PATCH / DELETE/api/keys/{id}Get a key, edit its name/status/budget, or delete it
GET/api/keys/{id}/discountsRead the effective discounts for your key
GET / PATCH/api/user/profileRead account details or update your name
GET/api/usageRequest details and usage totals, filterable by key, model, and time
GET/api/v1/billing/usageRequest details and usage totals, filterable by key, model, and time
GET/api/v1/billing/spendingAccount spending trends
GET/api/v1/billing/invoicesList invoices
GET / POST/api/v1/billing/budgetRead or configure account budgets
export TOKENHUB_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
export TOKENHUB_USER_ID="YOUR_USER_ID"

curl "https://tokenhub.store/api/balance" \
  -H "Authorization: Bearer $TOKENHUB_ACCESS_TOKEN" \
  -H "TokenHub-User: $TOKENHUB_USER_ID"

curl "https://tokenhub.store/api/keys" \
  -H "Authorization: Bearer $TOKENHUB_ACCESS_TOKEN" \
  -H "TokenHub-User: $TOKENHUB_USER_ID" \
  -H "Content-Type: application/json" \
  -d '{"name":"My application","spendLimit":10}'

curl --get "https://tokenhub.store/api/v1/billing/usage" \
  -H "Authorization: Bearer $TOKENHUB_ACCESS_TOKEN" \
  -H "TokenHub-User: $TOKENHUB_USER_ID" \
  --data-urlencode "apiKeyId=YOUR_API_KEY_ID" \
  --data-urlencode "model=alibaba/qwen-turbo" \
  --data-urlencode "startDate=2026-09-07T00:00:00Z" \
  --data-urlencode "endDate=2026-09-08T00:00:00Z" \
  --data-urlencode "page=1" \
  --data-urlencode "limit=20"

Usage filters: apiKeyId is the ID returned by /api/keys, not the th- secret. model matches the full model ID exactly. Send startDate and endDate together as ISO timestamps with a timezone (inclusive boundaries). page defaults to 1; limit defaults to 20, maximum 100. Summary covers all matching records. Omit apiKeyId to query the account. An unknown key or a key owned by another account returns 404. API keys retain their existing account-wide billing access. /api/usage also accepts start_date/end_date, one-sided ranges, limit (default 100, maximum 1000), and offset (default 0).

Create: name=My application, spendLimit=10; omit spendLimit for the shared wallet. PATCH accepts name, isActive, and action (set_limit, add_budget, clear_limit, reset_spent); set_limit/add_budget also need a non-negative value. set_limit resets spent; add_budget preserves spent for an existing cap. GET /api/keys/:id returns the full model key. Deleting a key removes its UsageLog association; use isActive:false to retain usage filtering by key.

API キーは名前または先頭部分で検索でき、1 ページに 20 件表示されます。新しいキーは最初のページに表示されます。別のウィンドウや API で作成したキーを表示するには、一覧を更新してください。 API Keys

One active access token per account. It remains valid until regenerated or revoked; the database stores only its hash. Token lifecycle endpoints GET/POST/DELETE /api/user/access-token require a browser login. Tokens cannot manage their own lifecycle or authorize admin, password, account-deletion, or model-generation endpoints. Invalid tokens or mismatched user IDs return 401. Existing browser-session authentication continues to work.

コード例

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