透過 TokenHub 統一的 /chat/completions 端點呼叫 DeepSeek 2026 旗艦 V4 系列(V4-Pro 與 V4-Flash)。完整相容 OpenAI — 官方 openai SDK 可直接使用。支援串流、工具使用,以及帶有 reasoning_content 的思考模式。1M context window、384K max output,依 DeepSeek catalog 定價按 token 計費。
th-xxxxxxxxxxxx...)https://tokenhub.store/api/v1在 Authorization 標頭中帶入 API Key:
Authorization: Bearer th-your-api-keyPOST/chat/completions聊天完成。與 OpenAI /v1/chat/completions 使用相同 schema,支援串流、tools、JSON mode 以及 DeepSeek 專屬思考欄位。
價格以每 100 萬 tokens(USD)計算,依 DeepSeek catalog 列價(未套用促銷折扣)。可接受 canonical ID 與 deepseek/* alias。Billing 以上游回傳的 completion_tokens 計費(其已包含 reasoning_tokens)。
| 方案 | Model ID | 輸入 | 輸出 | 備註 |
|---|---|---|---|---|
| V4-Pro | deepseek-v4-pro | $1.80 | $3.60 | 2026 頂級旗艦。最佳推理與程式碼品質。 |
| V4-Flash | deepseek-v4-flash | $0.15 | $0.30 | 超高性價比旗艦,約為 Pro 的 12 倍更便宜;非常適合作為生產環境預設值。 |
| 參數 | 型別 | 是否必填 | 預設值 | 說明 |
|---|---|---|---|---|
| model | string | 必填 | — | DeepSeek V4 的 model ID。範例:"deepseek/deepseek-v4-flash"。 |
| messages | array | 必填 | — | 對話歷史。每個項目為 { role, content }。role ∈ system | user | assistant | tool。 |
| max_tokens | integer | 選填 | upstream default | 最大輸出 tokens。若未提供,DeepSeek 會使用其上游預設值(最高可達 384K)。在思考模式下,計數會包含 reasoning tokens — 不要設得太小。 |
| temperature | number | 選填 | 1.0 | 採樣 temperature,0.0–2.0。越低越具決定性。DeepSeek 建議程式碼使用 0.0,創意寫作使用 1.3。 |
| top_p | number | 選填 | 1.0 | Nucleus sampling。請使用 temperature 或 top_p,勿同時使用兩者。 |
| stream | boolean | 選填 | false | 若為 true,則回傳 Server-Sent Events(SSE)增量。 |
| thinking | object | 選填 | {type:'enabled'} | DeepSeek 專屬。透過 extra_body 傳入 { type: 'disabled' } 可跳過推理階段,以獲得更快/更便宜的回應。預設:enabled。 |
| reasoning_effort | string | 選填 | medium | 思考深度:low | medium | high。越高 = 更多 reasoning tokens、更佳品質、更高成本。 |
| tools | array | 選填 | — | 供 tool use(function calling)使用的工具/函式定義清單。 |
| tool_choice | string|object | 選填 | auto | 控制工具選擇:auto | none | required | { type:'function', function:{ name } }。 |
| response_format | object | 選填 | — | JSON mode: { "type": "json_object" } 強制 model 回傳有效的 JSON。 |
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
}'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)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);DeepSeek V4 會在產生最終答案前先開啟專門的推理階段。以下是你需要知道的:
註冊 TokenHub,透過我們 OpenAI-compatible API 開始呼叫 DeepSeek V4