Class: OpenAI::Resources::Batches
- Inherits:
-
Object
- Object
- OpenAI::Resources::Batches
- Defined in:
- lib/openai/resources/batches.rb,
sig/openai/resources/batches.rbs
Overview
Create large batches of API requests to run asynchronously.
Instance Method Summary collapse
-
#cancel(batch_id, request_options: {}) ⇒ OpenAI::Models::Batch
Cancels an in-progress batch.
-
#create(completion_window:, endpoint:, input_file_id:, metadata: nil, output_expires_after: nil, request_options: {}) ⇒ OpenAI::Models::Batch
Some parameter documentations has been truncated, see Models::BatchCreateParams for more details.
-
#initialize(client:) ⇒ Batches
constructor
private
A new instance of Batches.
-
#list(after: nil, limit: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Batch>
Some parameter documentations has been truncated, see Models::BatchListParams for more details.
-
#retrieve(batch_id, request_options: {}) ⇒ OpenAI::Models::Batch
Retrieves a batch.
Constructor Details
#initialize(client:) ⇒ Batches
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Batches.
118 119 120 |
# File 'lib/openai/resources/batches.rb', line 118 def initialize(client:) @client = client end |
Instance Method Details
#cancel(batch_id, request_options: {}) ⇒ OpenAI::Models::Batch
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.
105 106 107 108 109 110 111 112 113 |
# File 'lib/openai/resources/batches.rb', line 105 def cancel(batch_id, params = {}) @client.request( method: :post, path: ["batches/%1$s/cancel", batch_id], model: OpenAI::Batch, security: {bearer_auth: true}, options: params[:request_options] ) end |
#create(completion_window:, endpoint:, input_file_id:, metadata: nil, output_expires_after: nil, request_options: {}) ⇒ OpenAI::Models::Batch
Some parameter documentations has been truncated, see Models::BatchCreateParams for more details.
Creates and executes a batch from an uploaded file of requests
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/openai/resources/batches.rb', line 29 def create(params) parsed, = OpenAI::BatchCreateParams.dump_request(params) @client.request( method: :post, path: "batches", body: parsed, model: OpenAI::Batch, security: {bearer_auth: true}, options: ) end |
#list(after: nil, limit: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Batch>
Some parameter documentations has been truncated, see Models::BatchListParams for more details.
List your organization's batches.
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/openai/resources/batches.rb', line 78 def list(params = {}) parsed, = OpenAI::BatchListParams.dump_request(params) query = OpenAI::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "batches", query: query, page: OpenAI::Internal::CursorPage, model: OpenAI::Batch, security: {bearer_auth: true}, options: ) end |
#retrieve(batch_id, request_options: {}) ⇒ OpenAI::Models::Batch
Retrieves a batch.
52 53 54 55 56 57 58 59 60 |
# File 'lib/openai/resources/batches.rb', line 52 def retrieve(batch_id, params = {}) @client.request( method: :get, path: ["batches/%1$s", batch_id], model: OpenAI::Batch, security: {bearer_auth: true}, options: params[:request_options] ) end |