Table of Contents

Class BatchEndpoint

Namespace
OpenAI.Batch
Assembly
OpenAI-DotNet.dll

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

string

Methods

CancelBatchAsync(string, CancellationToken)

Cancels an in-progress batch.

public Task<bool> CancelBatchAsync(string batchId, CancellationToken cancellationToken = default)

Parameters

batchId string
cancellationToken CancellationToken

Optional CancellationToken.

Returns

Task<bool>

True, if the batch was cancelled, otherwise false.

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 CreateBatchRequest

CreateBatchRequest.

cancellationToken CancellationToken

Optional CancellationToken.

Returns

Task<BatchResponse>

BatchResponse.

ListBatchesAsync(ListQuery, CancellationToken)

List your organization's batches.

public Task<ListResponse<BatchResponse>> ListBatchesAsync(ListQuery query = null, CancellationToken cancellationToken = default)

Parameters

query ListQuery

ListQuery.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<ListResponse<BatchResponse>>

ListResponse<TObject>.

RetrieveBatchAsync(string, CancellationToken)

Retrieves a batch.

public Task<BatchResponse> RetrieveBatchAsync(string batchId, CancellationToken cancellationToken = default)

Parameters

batchId string

The ID of the batch to retrieve.

cancellationToken CancellationToken

Optional CancellationToken.

Returns

Task<BatchResponse>

BatchResponse.