View Source OpenAi.Batch (OpenAI REST API Client v0.4.4)

Provides API endpoints related to batch

Summary

Functions

Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will have partial results (if any) available in the output file.

Creates and executes a batch from an uploaded file of requests

List your organization's batches.

Types

@type t() :: %OpenAi.Batch{
  cancelled_at: integer() | nil,
  cancelling_at: integer() | nil,
  completed_at: integer() | nil,
  completion_window: String.t(),
  created_at: integer(),
  endpoint: String.t(),
  error_file_id: String.t() | nil,
  errors: OpenAi.Batch.Errors.t() | nil,
  expired_at: integer() | nil,
  expires_at: integer() | nil,
  failed_at: integer() | nil,
  finalizing_at: integer() | nil,
  id: String.t(),
  in_progress_at: integer() | nil,
  input_file_id: String.t(),
  metadata: map() | nil,
  object: String.t(),
  output_file_id: String.t() | nil,
  request_counts: OpenAi.Batch.RequestCounts.t() | nil,
  status: String.t()
}

Functions

Link to this function

cancel_batch(batch_id, opts \\ [])

View Source
@spec cancel_batch(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, OpenAi.Error.error()}

Cancels an in-progress batch. The batch will be in status cancelling for up to 10 minutes, before changing to cancelled, where it will have partial results (if any) available in the output file.

Link to this function

create_batch(body, opts \\ [])

View Source
@spec create_batch(
  map(),
  keyword()
) :: {:ok, t()} | {:error, OpenAi.Error.error()}

Creates and executes a batch from an uploaded file of requests

Link to this function

list_batches(opts \\ [])

View Source
@spec list_batches(keyword()) ::
  {:ok, OpenAi.Batch.ListResponse.t()} | {:error, OpenAi.Error.error()}

List your organization's batches.

Options

  • after: A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Link to this function

retrieve_batch(batch_id, opts \\ [])

View Source
@spec retrieve_batch(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, OpenAi.Error.error()}

Retrieves a batch.