Expand description
Batch API client for OpenAI and Anthropic batch processing.
Provides a unified interface for submitting, polling, and retrieving results from batch API endpoints:
- OpenAI Batch API: POST /v1/batches (JSONL file upload + batch creation)
- Anthropic Batch API: POST /v1/messages/batches (inline requests array)
§Example
ⓘ
use langchainrust::core::batch::{BatchClient, BatchProvider, BatchRequest};
use langchainrust::Message;
let client = BatchClient::new(BatchProvider::OpenAI, "sk-...");
let requests = vec![
BatchRequest {
custom_id: "req-1".into(),
messages: vec![Message::human("Hello")],
model: "gpt-4o".into(),
temperature: None,
max_tokens: None,
},
];
// let batch_id = client.submit(requests).await?;
// let results = client.submit_and_wait(requests, 5000, 300_000).await?;Structs§
- Batch
Client - Client for submitting, polling, and retrieving batch results.
- BatchId
- Batch identifier returned after submission.
- Batch
Request - A single request in a batch.
- Batch
Result - Result for a single request in a completed batch.
Enums§
- Batch
Error - Error type for batch operations.
- Batch
Provider - Batch provider type.
- Batch
Status - Status of a batch job.