D
DeepSeek API ガイド

TokenHub 上の DeepSeek V4 — OpenAI-Compatible な推論モデル

TokenHub の統一 /chat/completions エンドポイント経由で、DeepSeek の2026年旗艦 V4 シリーズ(V4-Pro と V4-Flash)を呼び出せます。完全な OpenAI-compatible で、公式 openai SDK がそのまま動作します。streaming、ツール使用、reasoning_content を使った思考モードもすべてサポートしています。1M のコンテキストウィンドウ、384K の max output、課金は DeepSeek カタログ価格に基づくトークン単位です。

OpenAI-CompatibleStreamingThinking ModeTool Use1M Context384K Output

1API Key を取得する

  1. こちらにアクセス tokenhub.store してアカウントを登録します(GitHub / Google サインインに対応)
  2. Dashboard → API Keys に移動し、"Create New Key" をクリックします
  3. Dashboard → Billing に移動して Credits を追加します(1 Credit = $1 USD)
  4. API Key をコピーします(形式: th-xxxxxxxxxxxx...)
⚠️ API Key は作成時に1回だけ表示されます。安全に保存してください。紛失した場合は新しいものを作成してください。

2API 概要

Base URL

https://tokenhub.store/api/v1

認証

Authorization ヘッダーに API Key を指定します:

Header
Authorization: Bearer th-your-api-key

エンドポイント(OpenAI-compatible)

POST
/chat/completions

Chat completion。OpenAI /v1/chat/completions と同じスキーマで、streaming、tools、JSON mode、DeepSeek 固有の thinking フィールドに対応しています。

公式 openai SDK をそのまま利用できます。base_url を TokenHub に向け、TokenHub API key を使うだけです。その他のコード変更は不要です。

3モデルと料金

料金は 100万 tokens あたりの USD です。DeepSeek のカタログ定価に基づきます(プロモーション割引なし)。正規 ID と deepseek/* エイリアスの両方が利用できます。課金は upstream が返す completion_tokens に基づきます(reasoning_tokens もすでに含まれています)。

ティアModel ID入力出力備考
V4-Prodeepseek-v4-pro$1.80$3.602026年の最上位フラッグシップ。推論とコーディング品質が最も優れています。
V4-Flashdeepseek-v4-flash$0.15$0.30非常にコスト効率の高いフラッグシップで、Pro より約12倍安価です。本番環境のデフォルトに最適です。

4リクエストパラメータ

パラメータ必須デフォルト説明
modelstring必須DeepSeek V4 の model ID。例: "deepseek/deepseek-v4-flash"。
messagesarray必須Chat history。各項目は { role, content } です。role ∈ system | user | assistant | tool。
max_tokensinteger任意upstream default最大出力 tokens。省略した場合、DeepSeek は upstream のデフォルトを使用します(最大 384K)。thinking モードではカウンタに reasoning tokens も含まれるため、小さく設定しすぎないでください。
temperaturenumber任意1.0Sampling temperature、0.0〜2.0。低いほど決定的になります。DeepSeek は code には 0.0、創作文章には 1.3 を推奨しています。
top_pnumber任意1.0ヌクレウスサンプリング。temperature または top_p のどちらか一方のみを使用してください。
streamboolean任意falsetrue の場合、Server-Sent Events (SSE) の差分を返します。
thinkingobject任意{type:'enabled'}DeepSeek 固有です。extra_body 経由で { type: 'disabled' } を渡すと、推論フェーズを省略してより高速・低コストな応答にできます。デフォルト: enabled。
reasoning_effortstring任意medium思考の深さ: low | medium | high。高いほど reasoning tokens が増え、品質は向上しますがコストも上がります。
toolsarray任意tool use (function calling) 用の tool/function 定義の一覧です。
tool_choicestring|object任意autotool の選択を制御します: auto | none | required | { type:'function', function:{ name } }。
response_formatobject任意JSON mode: { "type": "json_object" } により、model は有効な JSON を返すようになります。

5curl の例

bash
curl https://tokenhub.store/api/v1/chat/completions \
  -H "Authorization: Bearer th-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4-flash",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain CAP theorem in 3 bullets."}
    ],
    "temperature": 0.3
  }'

6Python の例

python
from openai import OpenAI

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

resp = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    temperature=0.3,
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain CAP theorem in 3 bullets."},
    ],
)

msg = resp.choices[0].message
# DeepSeek V4 returns the chain-of-thought in a separate field
print("Thinking:", getattr(msg, "reasoning_content", None))
print("Answer:  ", msg.content)
print("Usage:   ", resp.usage)

7JavaScript / Node.js の例

typescript
import OpenAI from "openai";

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

const resp = await client.chat.completions.create({
  model: "deepseek/deepseek-v4-flash",
  temperature: 0.3,
  messages: [
    { role: "system", content: "You are a concise assistant." },
    { role: "user", content: "Explain CAP theorem in 3 bullets." },
  ],
});

const msg: any = resp.choices[0].message;
console.log("Thinking:", msg.reasoning_content);
console.log("Answer:  ", msg.content);
console.log("Usage:   ", resp.usage);

8Thinking Mode の詳細

DeepSeek V4 は最終回答を書く前に専用の reasoning フェーズを開きます。知っておくべき点は次のとおりです:

  • reasoning_content は assistant メッセージ上の SEPARATE なフィールドとして返されます(content の中には含まれません)。次のターンで再送しないでください。
  • usage の completion_tokens には reasoning_tokens がすでに含まれています。請求もこれに基づきます。どれだけ thinking に使われたかは completion_tokens_details.reasoning_tokens を確認してください。
  • thinking モードで max_tokens を低くしすぎると、content が空になります(すべての tokens が reasoning に消費されるため)。未設定にするか、少なくとも 2000+ を指定してください。
  • レイテンシ重視のシナリオ(チャット、分類、簡単な抽出)では、extra_body: { thinking: { type: 'disabled' } } で無効化できます。
  • reasoning_effort: 'low' | 'medium' | 'high' は model の思考量を制御します。'high' は数学/コーディングで最良の結果を出し、'low' は高速です。
  • プロンプトキャッシュ: 同じ system プロンプトを再利用すると、DeepSeek は prompt_cache_hit_tokens を別途返します。TokenHub では現在、ミス率に基づいて一律課金しています(予測可能な料金との引き換えに、わずかな過請求があります)。

9FAQ

利用を始める準備はできましたか?

TokenHub に登録して、OpenAI-compatible API 経由で DeepSeek V4 の呼び出しを始めましょう