擷取訊息批次結果
GET/v1/messages/batches/{message_batch_id}/results
以 .jsonl 檔案的形式串流傳輸訊息批次的結果。
檔案中的每一行都是一個 JSON 物件,包含訊息批次中單一請求的結果。結果的順序不保證與請求的順序相同。請使用 custom_id 欄位將結果與請求配對。
在我們的使用者指南中進一步瞭解 Message Batches API
Parameters
Returns
擷取訊息批次結果
package main
import (
"context"
"fmt"
"github.com/anthropics/anthropic-sdk-go"
"github.com/anthropics/anthropic-sdk-go/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey("my-anthropic-api-key"),
)
stream := client.Messages.Batches.ResultsStreaming(
context.TODO(),
"message_batch_id",
anthropic.MessageBatchResultsParams{},
)
for stream.Next() {
fmt.Printf("%+v\n", stream.Current())
}
err := stream.Err()
if err != nil {
panic(err.Error())
}
}