pub struct BatchClient { /* private fields */ }Expand description
Client for submitting, polling, and retrieving batch results.
Implementations§
Source§impl BatchClient
impl BatchClient
Sourcepub fn new(provider: BatchProvider, api_key: impl Into<String>) -> Self
pub fn new(provider: BatchProvider, api_key: impl Into<String>) -> Self
Creates a new BatchClient for the given provider.
Sourcepub fn with_base_url(self, url: impl Into<String>) -> Self
pub fn with_base_url(self, url: impl Into<String>) -> Self
Overrides the base URL (useful for proxies or compatible endpoints).
Sourcepub async fn submit(
&self,
requests: Vec<BatchRequest>,
) -> Result<BatchId, BatchError>
pub async fn submit( &self, requests: Vec<BatchRequest>, ) -> Result<BatchId, BatchError>
Submit a batch of requests. Returns the batch ID.
For OpenAI: uploads a JSONL file via the Files API, then creates a
batch via POST /v1/batches referencing the uploaded file.
For Anthropic: creates a batch via POST /v1/messages/batches with
the requests array inline.
Sourcepub async fn poll(&self, id: &BatchId) -> Result<BatchStatus, BatchError>
pub async fn poll(&self, id: &BatchId) -> Result<BatchStatus, BatchError>
Poll the status of a batch job.
Sourcepub async fn results(
&self,
id: &BatchId,
) -> Result<Vec<BatchResult>, BatchError>
pub async fn results( &self, id: &BatchId, ) -> Result<Vec<BatchResult>, BatchError>
Retrieve results of a completed batch.
Sourcepub async fn submit_and_wait(
&self,
requests: Vec<BatchRequest>,
poll_interval_ms: u64,
max_wait_ms: u64,
) -> Result<Vec<BatchResult>, BatchError>
pub async fn submit_and_wait( &self, requests: Vec<BatchRequest>, poll_interval_ms: u64, max_wait_ms: u64, ) -> Result<Vec<BatchResult>, BatchError>
Submit and wait until complete, then return results.
Polls every poll_interval_ms milliseconds. Returns
BatchError::Timeout if max_wait_ms is exceeded.
Auto Trait Implementations§
impl !RefUnwindSafe for BatchClient
impl !UnwindSafe for BatchClient
impl Freeze for BatchClient
impl Send for BatchClient
impl Sync for BatchClient
impl Unpin for BatchClient
impl UnsafeUnpin for BatchClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more