Class BatchEndpoint
Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours for a 50% discount. https://platform.openai.com/docs/api-reference/batch
public sealed class BatchEndpoint : OpenAIBaseEndpoint
- Inheritance
-
BatchEndpoint
- Inherited Members
Constructors
BatchEndpoint(OpenAIClient)
public BatchEndpoint(OpenAIClient client)
Parameters
client
OpenAIClient
Properties
Root
The root endpoint address.
protected override string Root { get; }
Property Value
Methods
CancelBatchAsync(string, CancellationToken)
Cancels an in-progress batch.
public Task<bool> CancelBatchAsync(string batchId, CancellationToken cancellationToken = default)
Parameters
batchId
stringcancellationToken
CancellationTokenOptional CancellationToken.
Returns
CreateBatchAsync(CreateBatchRequest, CancellationToken)
Creates and executes a batch from an uploaded file of requests.
public Task<BatchResponse> CreateBatchAsync(CreateBatchRequest request, CancellationToken cancellationToken = default)
Parameters
request
CreateBatchRequestcancellationToken
CancellationTokenOptional CancellationToken.
Returns
ListBatchesAsync(ListQuery, CancellationToken)
List your organization's batches.
public Task<ListResponse<BatchResponse>> ListBatchesAsync(ListQuery query = null, CancellationToken cancellationToken = default)
Parameters
query
ListQuerycancellationToken
CancellationTokenOptional, CancellationToken.
Returns
RetrieveBatchAsync(string, CancellationToken)
Retrieves a batch.
public Task<BatchResponse> RetrieveBatchAsync(string batchId, CancellationToken cancellationToken = default)
Parameters
batchId
stringThe ID of the batch to retrieve.
cancellationToken
CancellationTokenOptional CancellationToken.