OpenAIBatchApi
Namespace: Vercel.AI.OpenAI
public sealed class OpenAIBatchApi : BatchResultsApiBase, IBatchApiOpenAI Batch API. Starts, reads, cancels, and lists Responses batches, and downloads their results.
Inheritance: object → BatchResultsApiBase
Implements: IBatchApi
Properties
Section titled “Properties”CanCancel
Section titled “CanCancel”public override bool CanCancel { get; }True when cancellation is implemented.
Value: bool
CanList
Section titled “CanList”public override bool CanList { get; }True when listing is implemented.
Value: bool
Provider
Section titled “Provider”public override string Provider { get; }Provider id.
Value: string
Methods
Section titled “Methods”DoCancelAsync(BatchOperationCall, CancellationToken)
Section titled “DoCancelAsync(BatchOperationCall, CancellationToken)”public override Task<BatchCancelResult> DoCancelAsync(BatchOperationCall call, CancellationToken cancellationToken)Cancels a batch.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchCancelResult>
DoGetResultsAsync(BatchOperationCall, CancellationToken)
Section titled “DoGetResultsAsync(BatchOperationCall, CancellationToken)”public override Task<IAsyncEnumerable<BatchItem>> DoGetResultsAsync(BatchOperationCall call, CancellationToken cancellationToken)Opens the result stream. Errors found while opening, such as a batch that is not complete, throw from the task. Errors found while reading, such as a malformed row, throw from the stream.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<IAsyncEnumerable<BatchItem>>
DoGetStatusAsync(BatchOperationCall, CancellationToken)
Section titled “DoGetStatusAsync(BatchOperationCall, CancellationToken)”public override Task<BatchStatus> DoGetStatusAsync(BatchOperationCall call, CancellationToken cancellationToken)Reads status.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchStatus>
DoListAsync(BatchOperationCall, CancellationToken)
Section titled “DoListAsync(BatchOperationCall, CancellationToken)”public override Task<BatchListResult> DoListAsync(BatchOperationCall call, CancellationToken cancellationToken)Lists batches. The implementation is invoked on this instance.
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchListResult>
DoStartAsync(BatchOperationCall, CancellationToken)
Section titled “DoStartAsync(BatchOperationCall, CancellationToken)”public override Task<BatchStartResult> DoStartAsync(BatchOperationCall call, CancellationToken cancellationToken)Uploads the requests as a JSONL input file, then creates a /v1/responses batch with a 24-hour completion window.
Every request must be a text request for the same model. providerOptions.openai.inputFileExpiresAfter sets the
input file TTL in seconds (3600 to 2592000, default 48 hours).
Parameters
| Name | Type | Description |
|---|---|---|
call |
BatchOperationCall | |
cancellationToken |
CancellationToken |
Returns: Task<BatchStartResult>
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product