OpenAI | Batch
Create large batches of API requests to run asynchronously. The Batch API returns completions within 24 hours at a 50% discount.
Simple Example
Create a batch job and retrieve its status.
OpenAI := TsgcHTTP_API_OpenAI.Create(nil);
OpenAI.OpenAIOptions.ApiKey := 'API_KEY';
// Create a batch
WriteLn(OpenAI._CreateBatch('file-abc123', '/v1/chat/completions'));
// List batches
WriteLn(OpenAI._ListBatches());
Methods
- CreateBatch: Creates and executes a batch from an uploaded file of requests.
- InputFileId: The ID of an uploaded file that contains requests for the batch.
- Endpoint: The endpoint to be used for all requests in the batch (e.g. /v1/chat/completions).
- CompletionWindow: (optional) The time frame within which the batch should be processed. Default is 24h.
- RetrieveBatch: Retrieves a batch by its ID.
- BatchId: The ID of the batch to retrieve.
- ListBatches: List your organization's batches.
- CancelBatch: Cancels an in-progress batch.
- BatchId: The ID of the batch to cancel.