TokenLab

파일 및 배치

메시지 배치 결과 조회

메시지 배치의 결과를 JSONL 형식으로 스트리밍합니다.

GET
/v1/messages/batches/{message_batch_id}/results

개요

메시지 배치의 결과를 JSONL 형식으로 한 번에 한 줄씩 스트리밍합니다. processing_status가 ended 상태가 된 후 결과를 읽으십시오. 이 URL은 배치 객체의 results_url과 동일합니다.

참고 사항

  • 각 줄은 {"custom_id": "...", "result": {...}} 형식입니다. 줄은 고정된 순서가 없으므로 custom_id를 통해 각각 매칭하십시오.
  • result.type은 succeeded(메시지 생성 (Create Message) 응답과 동일한 본문을 가진 message 포함), errored(error 포함), canceled 또는 expired입니다.
  • message 내의 model은 요청 시 전송한 모델 ID입니다.
  • 존재하지 않거나 삭제된 배치는 404를 반환합니다. 아직 읽을 준비가 되지 않은 배치는 409를 반환할 수 있으므로 나중에 다시 시도하십시오.

예시

요청

cURL
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"

응답 예시

응답

200 OK (JSONL)
{"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