Dosyalar ve toplu işler
Mesaj Toplu İşlem Sonuçlarını Alma
Bir Mesaj Toplu İşleminin sonuçlarını JSONL olarak yayınlar.
Genel Bakış
Bir Mesaj Toplu İşleminin sonuçlarını, her istek için bir satır olacak şekilde JSONL formatında yayınlayın. Sonuçları processing_status değeri ended olduktan sonra okuyun. Bu, toplu işlem nesnesindeki results_url ile aynı URL'dir.
Notlar
- Her satır
{"custom_id": "...", "result": {...}}şeklindedir. Satırlar belirli bir sırada değildir; her birinicustom_idile eşleştirin. result.typedeğerisucceeded(bir Mesaj Oluştur yanıtıyla aynı gövdeye sahipmessageile birlikte),errored(errorile birlikte),canceledveyaexpiredolabilir.messageiçindemodel, istekte gönderdiğiniz model kimliğidir.- Mevcut olmayan veya silinmiş bir toplu işlem
404döndürür. Henüz okunmaya hazır olmayan bir toplu işlem409döndürebilir; daha sonra tekrar deneyin.
İstek
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"Yanıt
{"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"}}Önemli alanlar
custom_idstring
İstekte belirlediğiniz
custom_id.result.typestring
succeeded, errored, canceled veya expired.result.messageobject
result.type değeri succeeded olduğunda mesaj.result.errorobject
result.type değeri errored olduğunda hata.Yetkilendirme
BearerAuth AuthorizationBearer <token>
API Anahtarı kimlik doğrulaması. API anahtarlarını Dashboard > API > API Keys bölümünden oluşturun veya yönetin.
Konum: header
Yol parametreleri
message_batch_id*string
Mesaj toplu iş tanımlayıcısı
Yanıt
application/x-ndjson
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json