Documentation Index
Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
Use this file to discover all available pages before exploring further.
概覽
此端點提供原生的 Anthropic Messages API 相容性。對於具備延伸思考等功能的 Claude 模型,請使用此端點。 此端點會保持 Anthropic 原生契約。messages 必須是 user / assistant 訊息陣列,system 應放在頂層 system 欄位,且 max_tokens 為必填。如果 payload 在 messages 中使用 OpenAI 的 system、developer 或 tool role,請改送 /v1/chat/completions。
Anthropic SDK 的 Base URL:
https://api.tokenlab.sh(不含 /v1 後綴)請求標頭
您的 TokenLab API 金鑰。可作為 Bearer token 的替代方案。
Anthropic API 版本。請使用
2023-06-01。請求主體
Claude 模型 ID(例如:
claude-sonnet-4-6 或 claude-opus-4-6)。訊息物件陣列,包含
role 與 content。要生成的最大 token 數量。
System prompt(與 messages 陣列分開)。
取樣溫度(0-1)。
啟用串流回應。
延伸思考設定(Claude Opus 4.5)。
type(string):設為"enabled"以啟用budget_tokens(integer):思考可使用的 token 預算
模型可用的工具。
模型應如何使用工具。選項:
auto、any、tool(指定工具)。Nucleus sampling 參數。請使用 temperature 或 top_p 其中之一,不要同時使用。
每個 token 僅從前 K 個選項中取樣。
自訂停止序列,當出現時模型將停止生成。
附加到請求上的中繼資料,用於追蹤目的。
回應
唯一的訊息識別碼。
一律為
message。一律為
assistant。內容區塊陣列(text、thinking、tool_use)。
所使用的模型。
生成停止的原因(
end_turn、max_tokens、tool_use)。Token 使用情況,包含
input_tokens 與 output_tokens。圖片輸入示例
對於支援視覺能力的 Claude 模型,請將圖片放在messages[].content 中,作為結構化圖片內容區塊傳入。
延伸思考範例
Anthropic 訊息批次
TokenLab 現在除了/v1/messages 之外,也提供原生 Anthropic Message Batches 流程。
可用路由:
POST /v1/messages/batchesGET /v1/messages/batchesGET /v1/messages/batches/:message_batch_idGET /v1/messages/batches/:message_batch_id/resultsPOST /v1/messages/batches/:message_batch_id/cancelDELETE /v1/messages/batches/:message_batch_id
- 使用同一把 TokenLab API key 與 Anthropic 原生請求標頭。
- 如果 batch item 引用了
file_id,也要加上anthropic-beta: files-api-2025-04-14。 - Batch job 會維持 Anthropic 原生請求/回應格式,同時 TokenLab 會追蹤其內部結算生命週期。