Class: OpenAI::Models::Batch

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/batch.rb,
sig/openai/models/batch.rbs

Overview

See Also:

  • OpenAI::Resources::Batches#create

Defined Under Namespace

Modules: Status Classes: Errors

Constant Summary collapse

OpenAI =

Returns:

  • (:BatchRequestCounts)

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_with_error, dump, #dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(id:, completion_window:, created_at:, endpoint:, input_file_id:, status:, cancelled_at: nil, cancelling_at: nil, completed_at: nil, error_file_id: nil, errors: nil, expired_at: nil, expires_at: nil, failed_at: nil, finalizing_at: nil, in_progress_at: nil, metadata: nil, model: nil, output_file_id: nil, request_counts: nil, usage: nil, object: :batch) ⇒ Object

Parameters:

  • completion_window —

    The time frame within which the batch should be processed.

  • created_at —

    The Unix timestamp (in seconds) for when the batch was created.

  • endpoint —

    The OpenAI API endpoint used by the batch.

  • input_file_id —

    The ID of the input file for the batch.

  • status —

    The current status of the batch.

  • cancelled_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch was cancelled.

  • cancelling_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch started cancelling.

  • completed_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch was completed.

  • error_file_id (defaults to: nil) —

    The ID of the file containing the outputs of requests with errors.

  • expired_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch expired.

  • expires_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch will expire.

  • failed_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch failed.

  • finalizing_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch started finalizing.

  • in_progress_at (defaults to: nil) —

    The Unix timestamp (in seconds) for when the batch started processing.

  • metadata (defaults to: nil) —

    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

    Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

  • model (defaults to: nil) —

    Model ID used to process the batch, like gpt-6-astra. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.

  • output_file_id (defaults to: nil) —

    The ID of the file containing the outputs of successfully executed requests.

  • request_counts (defaults to: nil) —

    The request counts for different statuses within the batch.

  • usage (defaults to: nil) —

    Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used. Only populated on batches created after September 7, 2025.

  • object (defaults to: :batch) —

    The object type, which is always batch.



# File 'lib/openai/models/batch.rb', line 148

Instance Attribute Details

#cancelled_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch was cancelled.

Returns:

  • (Integer, nil)


52
# File 'lib/openai/models/batch.rb', line 52

optional :cancelled_at, Integer

#cancelling_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch started cancelling.

Returns:

  • (Integer, nil)


58
# File 'lib/openai/models/batch.rb', line 58

optional :cancelling_at, Integer

#completed_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch was completed.

Returns:

  • (Integer, nil)


64
# File 'lib/openai/models/batch.rb', line 64

optional :completed_at, Integer

#completion_window ⇒ String

The time frame within which the batch should be processed.

Returns:

  • (String)


16
# File 'lib/openai/models/batch.rb', line 16

required :completion_window, String

#created_at ⇒ Integer

The Unix timestamp (in seconds) for when the batch was created.

Returns:

  • (Integer)


22
# File 'lib/openai/models/batch.rb', line 22

required :created_at, Integer

#endpoint ⇒ String

The OpenAI API endpoint used by the batch.

Returns:

  • (String)


28
# File 'lib/openai/models/batch.rb', line 28

required :endpoint, String

#error_file_id ⇒ String?

The ID of the file containing the outputs of requests with errors.

Returns:

  • (String, nil)


70
# File 'lib/openai/models/batch.rb', line 70

optional :error_file_id, String

#errors ⇒ OpenAI::Models::Batch::Errors?

Parameters:

  • (OpenAI::Batch::Errors)

Returns:



75
# File 'lib/openai/models/batch.rb', line 75

optional :errors, -> { OpenAI::Batch::Errors }

#expired_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch expired.

Returns:

  • (Integer, nil)


81
# File 'lib/openai/models/batch.rb', line 81

optional :expired_at, Integer

#expires_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch will expire.

Returns:

  • (Integer, nil)


87
# File 'lib/openai/models/batch.rb', line 87

optional :expires_at, Integer

#failed_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch failed.

Returns:

  • (Integer, nil)


93
# File 'lib/openai/models/batch.rb', line 93

optional :failed_at, Integer

#finalizing_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch started finalizing.

Returns:

  • (Integer, nil)


99
# File 'lib/openai/models/batch.rb', line 99

optional :finalizing_at, Integer

#id ⇒ String

Parameters:

  • value (String)

Returns:

  • (String)


10
# File 'lib/openai/models/batch.rb', line 10

required :id, String

#in_progress_at ⇒ Integer?

The Unix timestamp (in seconds) for when the batch started processing.

Returns:

  • (Integer, nil)


105
# File 'lib/openai/models/batch.rb', line 105

optional :in_progress_at, Integer

#input_file_id ⇒ String

The ID of the input file for the batch.

Returns:

  • (String)


34
# File 'lib/openai/models/batch.rb', line 34

required :input_file_id, String

#metadata ⇒ OpenAI::Models::metadata?

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

Returns:

  • (OpenAI::Models::metadata, nil)


116
# File 'lib/openai/models/batch.rb', line 116

optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true

#model ⇒ String?

Model ID used to process the batch, like gpt-6-astra. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.

Returns:

  • (String, nil)


126
# File 'lib/openai/models/batch.rb', line 126

optional :model, String

#object ⇒ :batch

The object type, which is always batch.

Returns:

  • (:batch)


40
# File 'lib/openai/models/batch.rb', line 40

required :object, const: :batch

#output_file_id ⇒ String?

The ID of the file containing the outputs of successfully executed requests.

Returns:

  • (String, nil)


132
# File 'lib/openai/models/batch.rb', line 132

optional :output_file_id, String

#request_counts ⇒ OpenAI::BatchRequestCounts?

The request counts for different statuses within the batch.

Returns:



138
# File 'lib/openai/models/batch.rb', line 138

optional :request_counts, -> { OpenAI::BatchRequestCounts }

#status ⇒ OpenAI::Models::Batch::status

The current status of the batch.

Returns:

  • (OpenAI::Models::Batch::status)


46
# File 'lib/openai/models/batch.rb', line 46

required :status, enum: -> { OpenAI::Batch::Status }

#usage ⇒ OpenAI::BatchUsage?

Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used. Only populated on batches created after September 7, 2025.

Returns:



146
# File 'lib/openai/models/batch.rb', line 146

optional :usage, -> { OpenAI::BatchUsage }

Class Method Details

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/openai/models/batch.rb', line 239

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


230
# File 'sig/openai/models/batch.rbs', line 230

def to_hash: -> {