檔案與批次
檢索訊息批次處理結果
以 JSONL 格式串流傳輸訊息批次處理的結果。
概覽
以 JSONL 格式串流傳輸訊息批次處理的結果,每行對應一個請求。請在 processing_status 為 ended 後讀取結果。此 URL 與批次物件中的 results_url 相同。
注意事項
- 每一行皆為
{"custom_id": "...", "result": {...}}。各行沒有固定順序;請透過custom_id進行匹配。 result.type可能為succeeded(包含message,與 建立訊息 (Create Message) 回應的主體相同)、errored(包含error)、canceled或expired。- 在
message中,model為您在請求中發送的模型 ID。 - 若批次不存在或已被刪除,將回傳
404。若批次尚未準備好讀取,可能會回傳409;請稍後重試。
請求
curl -X GET "https://api.tokenlab.sh/v1/messages/batches/msgbatch_01ABC123/results" \
-H "x-api-key: sk-your-api-key" \
-H "anthropic-version: 2023-06-01"回應
{"custom_id":"request-1","result":{"type":"succeeded","message":{"id":"msg_abc123","type":"message","role":"assistant","content":[{"type":"text","text":"Hello! How can I help you today?"}],"model":"claude-sonnet-5","stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":9}}}}
{"custom_id":"request-2","result":{"type":"errored","error":{"type":"error","error":{"type":"invalid_request_error","message":"messages: at least one message is required"}}}}
{"custom_id":"request-3","result":{"type":"canceled"}}
{"custom_id":"request-4","result":{"type":"expired"}}重要欄位
custom_idstring
您在請求中設定的
custom_id。result.typestring
succeeded、errored、canceled 或 expired。result.messageobject
當
result.type 為 succeeded 時的訊息內容。result.errorobject
當
result.type 為 errored 時的錯誤內容。授權
BearerAuth AuthorizationBearer <token>
API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。
位置: header
路徑參數
message_batch_id*string
訊息批次識別碼
回應
application/x-ndjson
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json