Berkas & batch
Mengambil Hasil Batch Pesan
Melakukan streaming hasil dari Message Batch sebagai JSONL.
Gambaran Umum
Lakukan streaming hasil dari Message Batch sebagai JSONL, satu baris per permintaan. Baca hasilnya setelah processing_status bernilai ended. Ini adalah URL yang sama dengan results_url di dalam objek batch.
Catatan
- Setiap baris adalah
{"custom_id": "...", "result": {...}}. Baris-baris tersebut tidak memiliki urutan tetap; cocokkan masing-masing berdasarkancustom_id. result.typebisa berupasucceeded(denganmessage, isi yang sama dengan respons Create Message),errored(denganerror),canceled, atauexpired.- Di dalam
message,modeladalah ID model yang Anda kirimkan dalam permintaan. - Batch yang tidak ada atau telah dihapus akan mengembalikan
404. Batch yang belum siap untuk dibaca dapat mengembalikan409; coba lagi nanti.
Permintaan
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"Respons
{"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"}}Bidang penting
custom_idstring
custom_id yang Anda tetapkan pada permintaan.result.typestring
succeeded, errored, canceled, atau expired.result.messageobject
Pesan tersebut, saat
result.type adalah succeeded.result.errorobject
Kesalahan tersebut, saat
result.type adalah errored.Otorisasi
BearerAuth AuthorizationBearer <token>
Autentikasi API Key. Buat atau kelola API key di Dashboard > API > API Keys.
Lokasi: header
Parameter path
message_batch_id*string
Pengidentifikasi batch pesan
Respons
application/x-ndjson
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json