ファイルとバッチ
メッセージバッチ結果の取得
メッセージバッチの結果をJSONLとしてストリームします。
概要
メッセージバッチの結果をJSONL形式で、1リクエストにつき1行ずつストリームします。processing_status が ended になった後に結果を読み取ってください。これはバッチオブジェクト内の results_url と同じ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キー認証。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