experimental_getBatchStatus

API Reference for experimental_getBatchStatus.

Batch support is experimental and the API may change in patch releases.

Retrieves the latest status of an asynchronous batch. For a complete guide to the batch lifecycle, see Batch.

import { anthropic } from '@ai-sdk/anthropic';
import { experimental_getBatchStatus as getBatchStatus } from 'ai';

const status = await getBatchStatus({
  provider: anthropic,
  batch,
});

console.log(status.status, status.requestCounts);

Import

import { experimental_getBatchStatus } from "ai"

API Signature

Parameters

provider?:

Experimental_BatchProvider
The provider used to access the batch. Defaults to the global provider, or the AI Gateway when no global provider is configured.

batch:

Experimental_BatchReference
The serializable reference returned by experimental_startBatch.

providerOptions?:

ProviderOptions
Additional provider-specific options for status retrieval.

maxRetries?:

number
Maximum number of retries for status retrieval. Set to 0 to disable retries. Default: 2.

abortSignal?:

AbortSignal
An optional abort signal to cancel the request.

timeout?:

number | { totalMs?: number }
Maximum time allowed for the status request.

headers?:

Record<string, string | undefined>
Additional HTTP headers for the request.

Returns

status:

'pending' | 'completed' | 'failed'
The latest normalized batch status.

rawStatus?:

string
The provider-specific batch status, when available.

error?:

Experimental_BatchError
Error details when the batch fails.

createdAt?:

string
Creation timestamp, when provided by the provider.

expiresAt?:

string
Expiration timestamp, when provided by the provider.

providerMetadata?:

ProviderMetadata
Provider-specific metadata for the batch.