Class: Anthropic::Resources::Messages::Batches
- Inherits:
-
Object
- Object
- Anthropic::Resources::Messages::Batches
- Defined in:
- lib/anthropic/resources/messages/batches.rb
Instance Method Summary collapse
-
#cancel(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
Batches may be canceled any time before processing ends.
-
#create(requests: , request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
Some parameter documentations has been truncated, see Models::Messages::BatchCreateParams for more details.
-
#delete(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::DeletedMessageBatch
Delete a Message Batch.
-
#initialize(client:) ⇒ Batches
constructor
private
A new instance of Batches.
-
#list(after_id: nil, before_id: nil, limit: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Messages::MessageBatch>
Some parameter documentations has been truncated, see Models::Messages::BatchListParams for more details.
-
#results_streaming(message_batch_id, request_options: {}) ⇒ Anthropic::Internal::JsonLStream<Anthropic::Models::Messages::MessageBatchIndividualResponse>
Streams the results of a Message Batch as a
.jsonlfile. -
#retrieve(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
This endpoint is idempotent and can be used to poll for Message Batch completion.
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.
187 188 189 |
# File 'lib/anthropic/resources/messages/batches.rb', line 187 def initialize(client:) @client = client end |
Instance Method Details
#cancel(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
Batches may be canceled any time before processing ends. Once cancellation is
initiated, the batch enters a canceling state, at which time the system may
complete any in-progress, non-interruptible requests before finalizing
cancellation.
The number of canceled requests is specified in request_counts. To determine
which requests were canceled, check the individual results within the batch.
Note that cancellation may not result in any canceled requests if they were
non-interruptible.
Learn more about the Message Batches API in our user guide
146 147 148 149 150 151 152 153 |
# File 'lib/anthropic/resources/messages/batches.rb', line 146 def cancel(, params = {}) @client.request( method: :post, path: ["v1/messages/batches/%1$s/cancel", ], model: Anthropic::Messages::MessageBatch, options: params[:request_options] ) end |
#create(requests: , request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
Some parameter documentations has been truncated, see Models::Messages::BatchCreateParams for more details.
Send a batch of Message creation requests.
The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.
Learn more about the Message Batches API in our user guide
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/anthropic/resources/messages/batches.rb', line 28 def create(params) parsed, = Anthropic::Messages::BatchCreateParams.dump_request(params) @client.request( method: :post, path: "v1/messages/batches", body: parsed, model: Anthropic::Messages::MessageBatch, options: ) end |
#delete(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::DeletedMessageBatch
Delete a Message Batch.
Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.
Learn more about the Message Batches API in our user guide
115 116 117 118 119 120 121 122 |
# File 'lib/anthropic/resources/messages/batches.rb', line 115 def delete(, params = {}) @client.request( method: :delete, path: ["v1/messages/batches/%1$s", ], model: Anthropic::Messages::DeletedMessageBatch, options: params[:request_options] ) end |
#list(after_id: nil, before_id: nil, limit: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::Messages::MessageBatch>
Some parameter documentations has been truncated, see Models::Messages::BatchListParams for more details.
List all Message Batches within a Workspace. Most recently created batches are returned first.
Learn more about the Message Batches API in our user guide
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/anthropic/resources/messages/batches.rb', line 86 def list(params = {}) parsed, = Anthropic::Messages::BatchListParams.dump_request(params) @client.request( method: :get, path: "v1/messages/batches", query: parsed, page: Anthropic::Internal::Page, model: Anthropic::Messages::MessageBatch, options: ) end |
#results_streaming(message_batch_id, request_options: {}) ⇒ Anthropic::Internal::JsonLStream<Anthropic::Models::Messages::MessageBatchIndividualResponse>
Streams the results of a Message Batch as a .jsonl file.
Each line in the file is a JSON object containing the result of a single request
in the Message Batch. Results are not guaranteed to be in the same order as
requests. Use the custom_id field to match results to requests.
Learn more about the Message Batches API in our user guide
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/anthropic/resources/messages/batches.rb', line 173 def results_streaming(, params = {}) @client.request( method: :get, path: ["v1/messages/batches/%1$s/results", ], headers: {"accept" => "application/x-jsonl"}, stream: Anthropic::Internal::JsonLStream, model: Anthropic::Messages::MessageBatchIndividualResponse, options: params[:request_options] ) end |
#retrieve(message_batch_id, request_options: {}) ⇒ Anthropic::Models::Messages::MessageBatch
This endpoint is idempotent and can be used to poll for Message Batch
completion. To access the results of a Message Batch, make a request to the
results_url field in the response.
Learn more about the Message Batches API in our user guide
55 56 57 58 59 60 61 62 |
# File 'lib/anthropic/resources/messages/batches.rb', line 55 def retrieve(, params = {}) @client.request( method: :get, path: ["v1/messages/batches/%1$s", ], model: Anthropic::Messages::MessageBatch, options: params[:request_options] ) end |