From ff507d095ff703ba3b44ab82b06eb4314688d4eb Mon Sep 17 00:00:00 2001 From: dogisgreat Date: Sat, 9 Aug 2025 12:39:13 -0400 Subject: [PATCH 1/5] fix!: structured output desc should go on array items not array itself (#799) --- .../structured_outputs_chat_completions.rb | 2 +- examples/structured_outputs_responses.rb | 2 +- .../helpers/structured_output/array_of.rb | 12 +----- .../helpers/structured_output/base_model.rb | 15 ++------ .../json_schema_converter.rb | 22 +++++++++-- .../helpers/structured_output/union_of.rb | 12 +----- .../helpers/structured_output/array_of.rbi | 3 -- .../json_schema_converter.rbi | 10 +++++ test/openai/helpers/structured_output_test.rb | 37 +++++++++++-------- 9 files changed, 60 insertions(+), 55 deletions(-) diff --git a/examples/structured_outputs_chat_completions.rb b/examples/structured_outputs_chat_completions.rb index 11aa6728..707c741f 100755 --- a/examples/structured_outputs_chat_completions.rb +++ b/examples/structured_outputs_chat_completions.rb @@ -22,7 +22,7 @@ class CalendarEvent < OpenAI::BaseModel required :name, String required :date, String required :participants, OpenAI::ArrayOf[Participant] - required :optional_participants, OpenAI::ArrayOf[Participant], nil?: true + required :optional_participants, OpenAI::ArrayOf[Participant, doc: "who might not show up"], nil?: true required :is_virtual, OpenAI::Boolean required :location, OpenAI::UnionOf[String, Location], diff --git a/examples/structured_outputs_responses.rb b/examples/structured_outputs_responses.rb index 5a7be6ab..25aa4442 100755 --- a/examples/structured_outputs_responses.rb +++ b/examples/structured_outputs_responses.rb @@ -21,7 +21,7 @@ class CalendarEvent < OpenAI::BaseModel required :name, String required :date, String required :participants, OpenAI::ArrayOf[Participant] - required :optional_participants, OpenAI::ArrayOf[Participant], nil?: true + required :optional_participants, OpenAI::ArrayOf[Participant, doc: "who might not show up"], nil?: true required :is_virtual, OpenAI::Boolean required :location, OpenAI::UnionOf[String, Location], diff --git a/lib/openai/helpers/structured_output/array_of.rb b/lib/openai/helpers/structured_output/array_of.rb index cf134ea9..fb49cce1 100644 --- a/lib/openai/helpers/structured_output/array_of.rb +++ b/lib/openai/helpers/structured_output/array_of.rb @@ -30,19 +30,11 @@ def to_json_schema_inner(state:) state: state ) items = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_nilable(items) if nilable? + OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.assoc_meta!(items, meta: @meta) - schema = {type: "array", items: items} - description.nil? ? schema : schema.update(description: description) + {type: "array", items: items} end end - - # @return [String, nil] - attr_reader :description - - def initialize(type_info, spec = {}) - super - @description = [type_info, spec].grep(Hash).filter_map { _1[:doc] }.first - end end end end diff --git a/lib/openai/helpers/structured_output/base_model.rb b/lib/openai/helpers/structured_output/base_model.rb index 5294df80..a6914c26 100644 --- a/lib/openai/helpers/structured_output/base_model.rb +++ b/lib/openai/helpers/structured_output/base_model.rb @@ -28,15 +28,13 @@ def to_json_schema_inner(state:) OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do path = state.fetch(:path) properties = fields.to_h do |name, field| - type, nilable = field.fetch_values(:type, :nilable) + type, nilable, meta = field.fetch_values(:type, :nilable, :meta) new_state = {**state, path: [*path, ".#{name}"]} schema = case type - in {"$ref": String} - type in OpenAI::Helpers::StructuredOutput::JsonSchemaConverter - type.to_json_schema_inner(state: new_state).update(field.slice(:description)) + type.to_json_schema_inner(state: new_state) else OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema_inner( type, @@ -44,6 +42,8 @@ def to_json_schema_inner(state:) ) end schema = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_nilable(schema) if nilable + OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.assoc_meta!(schema, meta: meta) + [name, schema] end @@ -58,13 +58,6 @@ def to_json_schema_inner(state:) end class << self - def required(name_sym, type_info, spec = {}) - super - - doc = [type_info, spec].grep(Hash).filter_map { _1[:doc] }.first - known_fields.fetch(name_sym).update(description: doc) unless doc.nil? - end - def optional(...) # rubocop:disable Layout/LineLength message = "`optional` is not supported for structured output APIs, use `#required` with `nil?: true` instead" diff --git a/lib/openai/helpers/structured_output/json_schema_converter.rb b/lib/openai/helpers/structured_output/json_schema_converter.rb index 3a6c2ba9..35994f76 100644 --- a/lib/openai/helpers/structured_output/json_schema_converter.rb +++ b/lib/openai/helpers/structured_output/json_schema_converter.rb @@ -46,7 +46,7 @@ def to_nilable(schema) in {"$ref": String} { anyOf: [ - schema.update(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF => true), + schema.merge!(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF => true), {type: null} ] } @@ -60,6 +60,17 @@ def to_nilable(schema) end end + # @api private + # + # @param schema [Hash{Symbol=>Object}] + def assoc_meta!(schema, meta:) + xformed = meta.transform_keys(doc: :description) + if schema.key?(:$ref) && !xformed.empty? + schema.merge!(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF => true) + end + schema.merge!(xformed) + end + # @api private # # @param state [Hash{Symbol=>Object}] @@ -116,12 +127,17 @@ def to_json_schema(type) case refs in [ref] - ref.replace(sch) + ref.replace(ref.except(:$ref).merge(sch)) in [_, ref, *] reused_defs.store(ref.fetch(:$ref), sch) + refs.each do + unless (meta = _1.except(:$ref)).empty? + _1.replace(allOf: [_1.slice(:$ref), meta]) + end + end else end - no_refs.each { _1.replace(sch) } + no_refs.each { _1.replace(_1.except(:$ref).merge(sch)) } end xformed = reused_defs.transform_keys { _1.delete_prefix("#/$defs/") } diff --git a/lib/openai/helpers/structured_output/union_of.rb b/lib/openai/helpers/structured_output/union_of.rb index 5ae7086b..64dd3fff 100644 --- a/lib/openai/helpers/structured_output/union_of.rb +++ b/lib/openai/helpers/structured_output/union_of.rb @@ -56,16 +56,8 @@ def self.[](...) = new(...) # @param variants [Array>] def initialize(*variants) - case variants - in [Symbol => d, Hash => vs] - discriminator(d) - vs.each do |k, v| - v.is_a?(Proc) ? variant(k, v) : variant(k, -> { v }) - end - else - variants.each do |v| - v.is_a?(Proc) ? variant(v) : variant(-> { v }) - end + variants.each do |v| + v.is_a?(Proc) ? variant(v) : variant(-> { v }) end end end diff --git a/rbi/openai/helpers/structured_output/array_of.rbi b/rbi/openai/helpers/structured_output/array_of.rbi index b0c70ce6..a9d9cf14 100644 --- a/rbi/openai/helpers/structured_output/array_of.rbi +++ b/rbi/openai/helpers/structured_output/array_of.rbi @@ -7,9 +7,6 @@ module OpenAI include OpenAI::Helpers::StructuredOutput::JsonSchemaConverter Elem = type_member(:out) - - sig { returns(String) } - attr_reader :description end end end diff --git a/rbi/openai/helpers/structured_output/json_schema_converter.rbi b/rbi/openai/helpers/structured_output/json_schema_converter.rbi index f32e2d04..0174fade 100644 --- a/rbi/openai/helpers/structured_output/json_schema_converter.rbi +++ b/rbi/openai/helpers/structured_output/json_schema_converter.rbi @@ -46,6 +46,16 @@ module OpenAI def to_nilable(schema) end + # @api private + sig do + params( + schema: OpenAI::Helpers::StructuredOutput::JsonSchema, + meta: OpenAI::Internal::AnyHash + ).void + end + def assoc_meta!(schema, meta:) + end + # @api private sig do params( diff --git a/test/openai/helpers/structured_output_test.rb b/test/openai/helpers/structured_output_test.rb index 01cf9b0c..0cacaf9f 100644 --- a/test/openai/helpers/structured_output_test.rb +++ b/test/openai/helpers/structured_output_test.rb @@ -22,9 +22,10 @@ def test_misuse E1 = OpenAI::Helpers::StructuredOutput::EnumOf[:one] class M1 < OpenAI::Helpers::StructuredOutput::BaseModel - required :a, String + required :a, String, doc: "dog" required :b, Integer, nil?: true - required :c, E1, nil?: true + required :c, E1, nil?: true, doc: "dog" + required :d, E1, doc: "dog" end class M2 < OpenAI::Helpers::StructuredOutput::BaseModel @@ -36,7 +37,7 @@ class M3 < OpenAI::Helpers::StructuredOutput::BaseModel end U1 = OpenAI::Helpers::StructuredOutput::UnionOf[Integer, A1] - U2 = OpenAI::Helpers::StructuredOutput::UnionOf[:type, m2: M2, m3: M3] + U2 = OpenAI::Helpers::StructuredOutput::UnionOf[M2, M3] U3 = OpenAI::Helpers::StructuredOutput::UnionOf[A1, A1] def test_coerce @@ -78,18 +79,21 @@ def test_to_schema A1 => {type: "array", items: {type: "string"}}, OpenAI::Helpers::StructuredOutput::ArrayOf[String, nil?: true, doc: "a1"] => { type: "array", - items: {type: %w[string null]}, - description: "a1" + items: {type: %w[string null], description: "a1"} }, E1 => {type: "string", enum: ["one"]}, M1 => { type: "object", properties: { - a: {type: "string"}, + a: {type: "string", description: "dog"}, b: {type: %w[integer null]}, - c: {anyOf: [{type: "string", enum: %w[one]}, {type: "null"}]} + c: { + anyOf: [{type: "string", enum: ["one"]}, {type: "null"}], + description: "dog" + }, + d: {description: "dog", type: "string", enum: ["one"]} }, - required: %w[a b c], + required: %w[a b c d], additionalProperties: false }, U1 => { @@ -162,8 +166,9 @@ class M10 < OpenAI::Helpers::StructuredOutput::BaseModel class M11 < OpenAI::Helpers::StructuredOutput::BaseModel required :a, U3 - required :b, A1 + required :b, A1, doc: "dog" required :c, A1 + required :d, A1, doc: "dawg" end def test_definition_reusing @@ -311,20 +316,20 @@ def test_definition_reusing ] }, M11 => { - :$defs => {".a/?.0/[]" => {type: "array", items: {type: "string"}}}, - :type => "object", - :properties => { + type: "object", + properties: { a: { anyOf: [ {type: "array", items: {type: "string"}}, {type: "array", items: {type: "string"}} ] }, - b: {:$ref => "#/$defs/.a/?.0/[]"}, - c: {:$ref => "#/$defs/.a/?.0/[]"} + b: {description: "dog", type: "array", items: {type: "string"}}, + c: {type: "array", items: {type: "string"}}, + d: {description: "dawg", type: "array", items: {type: "string"}} }, - :required => %w[a b c], - :additionalProperties => false + required: %w[a b c d], + additionalProperties: false } } From 90fbd16d7025772d50d5d862c94b7db154cfd34a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:56:02 +0000 Subject: [PATCH 2/5] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 65629665..bbf5750e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 109 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6a1bfd4738fff02ef5becc3fdb2bf0cd6c026f2c924d4147a2a515474477dd9a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9cadfad609f94f20ebf74fdc06a80302f1a324dc69700a309a8056aabca82fd2.yml openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba -config_hash: a67c5e195a59855fe8a5db0dc61a3e7f +config_hash: 68337b532875626269c304372a669f67 From c815703062ce79d2cb14f252ee5d23cf4ebf15ca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:19:14 +0000 Subject: [PATCH 3/5] chore(internal): update test skipping reason --- test/openai/resources/audio/speech_test.rb | 2 +- test/openai/resources/containers/files/content_test.rb | 2 +- test/openai/resources/files_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/openai/resources/audio/speech_test.rb b/test/openai/resources/audio/speech_test.rb index f50614b3..af4189d5 100644 --- a/test/openai/resources/audio/speech_test.rb +++ b/test/openai/resources/audio/speech_test.rb @@ -4,7 +4,7 @@ class OpenAI::Test::Resources::Audio::SpeechTest < OpenAI::Test::ResourceTest def test_create_required_params - skip("skipped: test server currently has no support for method content-type") + skip("Prism doesn't support application/octet-stream responses") response = @openai.audio.speech.create(input: "input", model: :"tts-1", voice: :alloy) diff --git a/test/openai/resources/containers/files/content_test.rb b/test/openai/resources/containers/files/content_test.rb index 4d4252d4..0a57b6cb 100644 --- a/test/openai/resources/containers/files/content_test.rb +++ b/test/openai/resources/containers/files/content_test.rb @@ -4,7 +4,7 @@ class OpenAI::Test::Resources::Containers::Files::ContentTest < OpenAI::Test::ResourceTest def test_retrieve_required_params - skip("skipped: test server currently has no support for method content-type") + skip("Prism doesn't support application/binary responses") response = @openai.containers.files.content.retrieve("file_id", container_id: "container_id") diff --git a/test/openai/resources/files_test.rb b/test/openai/resources/files_test.rb index de03395e..5833751a 100644 --- a/test/openai/resources/files_test.rb +++ b/test/openai/resources/files_test.rb @@ -93,7 +93,7 @@ def test_delete end def test_content - skip("skipped: test server currently has no support for method content-type") + skip("Prism doesn't support application/binary responses") response = @openai.files.content("file_id") From f318432b19800ab42d5b0c5f179f0cdd02dbf596 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:12:09 +0000 Subject: [PATCH 4/5] feat(api): add new text parameters, expiration options --- .stats.yml | 6 +- lib/openai/models/batch_create_params.rb | 39 +++- .../beta/thread_create_and_run_params.rb | 4 +- lib/openai/models/beta/threads/run.rb | 4 +- .../models/beta/threads/run_create_params.rb | 4 +- lib/openai/models/chat/chat_completion.rb | 12 +- .../models/chat/chat_completion_chunk.rb | 12 +- .../models/chat/completion_create_params.rb | 53 ++++- lib/openai/models/file_create_params.rb | 38 +++- lib/openai/models/reasoning.rb | 2 +- lib/openai/models/responses/response.rb | 78 +++++-- .../responses/response_create_params.rb | 74 ++++++- lib/openai/models/upload_create_params.rb | 38 +++- lib/openai/resources/batches.rb | 4 +- lib/openai/resources/chat/completions.rb | 8 +- lib/openai/resources/files.rb | 6 +- lib/openai/resources/responses.rb | 8 +- lib/openai/resources/uploads.rb | 4 +- rbi/openai/models/batch_create_params.rbi | 60 ++++++ .../beta/thread_create_and_run_params.rbi | 6 +- rbi/openai/models/beta/threads/run.rbi | 6 +- .../models/beta/threads/run_create_params.rbi | 6 +- rbi/openai/models/chat/chat_completion.rbi | 15 +- .../models/chat/chat_completion_chunk.rbi | 15 +- .../models/chat/completion_create_params.rbi | 119 ++++++++++- rbi/openai/models/file_create_params.rbi | 56 +++++ rbi/openai/models/reasoning.rbi | 2 +- rbi/openai/models/responses/response.rbi | 180 +++++++++++++--- .../responses/response_create_params.rbi | 194 +++++++++++++++--- rbi/openai/models/upload_create_params.rbi | 56 +++++ rbi/openai/resources/batches.rbi | 5 + rbi/openai/resources/beta/threads.rbi | 4 +- rbi/openai/resources/beta/threads/runs.rbi | 4 +- rbi/openai/resources/chat/completions.rbi | 14 +- rbi/openai/resources/files.rbi | 6 +- rbi/openai/resources/responses.rbi | 24 +-- rbi/openai/resources/uploads.rbi | 4 + sig/openai/models/batch_create_params.rbs | 23 ++- .../models/chat/completion_create_params.rbs | 38 ++++ sig/openai/models/file_create_params.rbs | 23 ++- sig/openai/models/responses/response.rbs | 50 ++++- .../responses/response_create_params.rbs | 50 ++++- sig/openai/models/upload_create_params.rbs | 23 ++- sig/openai/resources/batches.rbs | 1 + sig/openai/resources/chat/completions.rbs | 2 + sig/openai/resources/files.rbs | 1 + sig/openai/resources/responses.rbs | 4 +- sig/openai/resources/uploads.rbs | 1 + test/openai/resources/responses_test.rb | 6 +- 49 files changed, 1188 insertions(+), 204 deletions(-) diff --git a/.stats.yml b/.stats.yml index bbf5750e..ce30bcee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 109 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9cadfad609f94f20ebf74fdc06a80302f1a324dc69700a309a8056aabca82fd2.yml -openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba -config_hash: 68337b532875626269c304372a669f67 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-24be531010b354303d741fc9247c1f84f75978f9f7de68aca92cb4f240a04722.yml +openapi_spec_hash: 3e46f439f6a863beadc71577eb4efa15 +config_hash: ed87b9139ac595a04a2162d754df2fed diff --git a/lib/openai/models/batch_create_params.rb b/lib/openai/models/batch_create_params.rb index 9b39fcd2..bdb51f2e 100644 --- a/lib/openai/models/batch_create_params.rb +++ b/lib/openai/models/batch_create_params.rb @@ -48,7 +48,14 @@ class BatchCreateParams < OpenAI::Internal::Type::BaseModel # @return [Hash{Symbol=>String}, nil] optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true - # @!method initialize(completion_window:, endpoint:, input_file_id:, metadata: nil, request_options: {}) + # @!attribute output_expires_after + # The expiration policy for the output and/or error file that are generated for a + # batch. + # + # @return [OpenAI::Models::BatchCreateParams::OutputExpiresAfter, nil] + optional :output_expires_after, -> { OpenAI::BatchCreateParams::OutputExpiresAfter } + + # @!method initialize(completion_window:, endpoint:, input_file_id:, metadata: nil, output_expires_after: nil, request_options: {}) # Some parameter documentations has been truncated, see # {OpenAI::Models::BatchCreateParams} for more details. # @@ -60,6 +67,8 @@ class BatchCreateParams < OpenAI::Internal::Type::BaseModel # # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be # + # @param output_expires_after [OpenAI::Models::BatchCreateParams::OutputExpiresAfter] The expiration policy for the output and/or error file that are generated for a + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] # The time frame within which the batch should be processed. Currently only `24h` @@ -88,6 +97,34 @@ module Endpoint # @!method self.values # @return [Array] end + + class OutputExpiresAfter < OpenAI::Internal::Type::BaseModel + # @!attribute anchor + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. Note that the anchor is the file creation time, not the time the + # batch is created. + # + # @return [Symbol, :created_at] + required :anchor, const: :created_at + + # @!attribute seconds + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + # + # @return [Integer] + required :seconds, Integer + + # @!method initialize(seconds:, anchor: :created_at) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::BatchCreateParams::OutputExpiresAfter} for more details. + # + # The expiration policy for the output and/or error file that are generated for a + # batch. + # + # @param seconds [Integer] The number of seconds after the anchor time that the file will expire. Must be b + # + # @param anchor [Symbol, :created_at] Anchor timestamp after which the expiration policy applies. Supported anchors: ` + end end end end diff --git a/lib/openai/models/beta/thread_create_and_run_params.rb b/lib/openai/models/beta/thread_create_and_run_params.rb index d244bcee..c53df32e 100644 --- a/lib/openai/models/beta/thread_create_and_run_params.rb +++ b/lib/openai/models/beta/thread_create_and_run_params.rb @@ -157,7 +157,7 @@ class ThreadCreateAndRunParams < OpenAI::Internal::Type::BaseModel # @!attribute truncation_strategy # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, nil] optional :truncation_strategy, @@ -694,7 +694,7 @@ class TruncationStrategy < OpenAI::Internal::Type::BaseModel # details. # # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @param type [Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to # diff --git a/lib/openai/models/beta/threads/run.rb b/lib/openai/models/beta/threads/run.rb index 2533a7a1..1f1b9746 100644 --- a/lib/openai/models/beta/threads/run.rb +++ b/lib/openai/models/beta/threads/run.rb @@ -195,7 +195,7 @@ class Run < OpenAI::Internal::Type::BaseModel # @!attribute truncation_strategy # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @return [OpenAI::Models::Beta::Threads::Run::TruncationStrategy, nil] required :truncation_strategy, -> { OpenAI::Beta::Threads::Run::TruncationStrategy }, nil?: true @@ -415,7 +415,7 @@ class TruncationStrategy < OpenAI::Internal::Type::BaseModel # {OpenAI::Models::Beta::Threads::Run::TruncationStrategy} for more details. # # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @param type [Symbol, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to # diff --git a/lib/openai/models/beta/threads/run_create_params.rb b/lib/openai/models/beta/threads/run_create_params.rb index 3c910eb7..43e028d1 100644 --- a/lib/openai/models/beta/threads/run_create_params.rb +++ b/lib/openai/models/beta/threads/run_create_params.rb @@ -184,7 +184,7 @@ class RunCreateParams < OpenAI::Internal::Type::BaseModel # @!attribute truncation_strategy # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @return [OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, nil] optional :truncation_strategy, @@ -413,7 +413,7 @@ class TruncationStrategy < OpenAI::Internal::Type::BaseModel # details. # # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. # # @param type [Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to # diff --git a/lib/openai/models/chat/chat_completion.rb b/lib/openai/models/chat/chat_completion.rb index f104825f..c288fe61 100644 --- a/lib/openai/models/chat/chat_completion.rb +++ b/lib/openai/models/chat/chat_completion.rb @@ -47,9 +47,8 @@ class ChatCompletion < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -61,6 +60,8 @@ class ChatCompletion < OpenAI::Internal::Type::BaseModel optional :service_tier, enum: -> { OpenAI::Chat::ChatCompletion::ServiceTier }, nil?: true # @!attribute system_fingerprint + # @deprecated + # # This fingerprint represents the backend configuration that the model runs with. # # Can be used in conjunction with the `seed` request parameter to understand when @@ -196,9 +197,8 @@ class Logprobs < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the diff --git a/lib/openai/models/chat/chat_completion_chunk.rb b/lib/openai/models/chat/chat_completion_chunk.rb index 52d7dcbc..25e97bc0 100644 --- a/lib/openai/models/chat/chat_completion_chunk.rb +++ b/lib/openai/models/chat/chat_completion_chunk.rb @@ -46,9 +46,8 @@ class ChatCompletionChunk < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -60,6 +59,8 @@ class ChatCompletionChunk < OpenAI::Internal::Type::BaseModel optional :service_tier, enum: -> { OpenAI::Chat::ChatCompletionChunk::ServiceTier }, nil?: true # @!attribute system_fingerprint + # @deprecated + # # This fingerprint represents the backend configuration that the model runs with. # Can be used in conjunction with the `seed` request parameter to understand when # backend changes have been made that might impact determinism. @@ -379,9 +380,8 @@ class Logprobs < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the diff --git a/lib/openai/models/chat/completion_create_params.rb b/lib/openai/models/chat/completion_create_params.rb index e95c14eb..9f15cf26 100644 --- a/lib/openai/models/chat/completion_create_params.rb +++ b/lib/openai/models/chat/completion_create_params.rb @@ -226,6 +226,8 @@ class CompletionCreateParams < OpenAI::Internal::Type::BaseModel optional :safety_identifier, String # @!attribute seed + # @deprecated + # # This feature is in Beta. If specified, our system will make a best effort to # sample deterministically, such that repeated requests with the same `seed` and # parameters should return the same result. Determinism is not guaranteed, and you @@ -244,9 +246,8 @@ class CompletionCreateParams < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -291,6 +292,11 @@ class CompletionCreateParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float, nil?: true + # @!attribute text + # + # @return [OpenAI::Models::Chat::CompletionCreateParams::Text, nil] + optional :text, -> { OpenAI::Chat::CompletionCreateParams::Text } + # @!attribute tool_choice # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can @@ -364,7 +370,7 @@ class CompletionCreateParams < OpenAI::Internal::Type::BaseModel # @return [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, nil] optional :web_search_options, -> { OpenAI::Chat::CompletionCreateParams::WebSearchOptions } - # @!method initialize(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) + # @!method initialize(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) # Some parameter documentations has been truncated, see # {OpenAI::Models::Chat::CompletionCreateParams} for more details. # @@ -420,6 +426,8 @@ class CompletionCreateParams < OpenAI::Internal::Type::BaseModel # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # + # @param text [OpenAI::Models::Chat::CompletionCreateParams::Text] + # # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionAllowedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoiceCustom] Controls which (if any) tool is called by the model. # # @param tools [Array] A list of tools the model may call. You can provide either @@ -591,9 +599,8 @@ module ResponseFormat # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -631,6 +638,38 @@ module Stop StringArray = OpenAI::Internal::Type::ArrayOf[String] end + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute verbosity + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @return [Symbol, OpenAI::Models::Chat::CompletionCreateParams::Text::Verbosity, nil] + optional :verbosity, enum: -> { OpenAI::Chat::CompletionCreateParams::Text::Verbosity }, nil?: true + + # @!method initialize(verbosity: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Chat::CompletionCreateParams::Text} for more details. + # + # @param verbosity [Symbol, OpenAI::Models::Chat::CompletionCreateParams::Text::Verbosity, nil] Constrains the verbosity of the model's response. Lower values will result in + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @see OpenAI::Models::Chat::CompletionCreateParams::Text#verbosity + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW = :low + MEDIUM = :medium + HIGH = :high + + # @!method self.values + # @return [Array] + end + end + # Constrains the verbosity of the model's response. Lower values will result in # more concise responses, while higher values will result in more verbose # responses. Currently supported values are `low`, `medium`, and `high`. diff --git a/lib/openai/models/file_create_params.rb b/lib/openai/models/file_create_params.rb index 44e48264..7de18db4 100644 --- a/lib/openai/models/file_create_params.rb +++ b/lib/openai/models/file_create_params.rb @@ -22,7 +22,14 @@ class FileCreateParams < OpenAI::Internal::Type::BaseModel # @return [Symbol, OpenAI::Models::FilePurpose] required :purpose, enum: -> { OpenAI::FilePurpose } - # @!method initialize(file:, purpose:, request_options: {}) + # @!attribute expires_after + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + # + # @return [OpenAI::Models::FileCreateParams::ExpiresAfter, nil] + optional :expires_after, -> { OpenAI::FileCreateParams::ExpiresAfter } + + # @!method initialize(file:, purpose:, expires_after: nil, request_options: {}) # Some parameter documentations has been truncated, see # {OpenAI::Models::FileCreateParams} for more details. # @@ -30,7 +37,36 @@ class FileCreateParams < OpenAI::Internal::Type::BaseModel # # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. One of: - `assistants`: Used in the A # + # @param expires_after [OpenAI::Models::FileCreateParams::ExpiresAfter] The expiration policy for a file. By default, files with `purpose=batch` expire + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + # @!attribute anchor + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + # + # @return [Symbol, :created_at] + required :anchor, const: :created_at + + # @!attribute seconds + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + # + # @return [Integer] + required :seconds, Integer + + # @!method initialize(seconds:, anchor: :created_at) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::FileCreateParams::ExpiresAfter} for more details. + # + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + # + # @param seconds [Integer] The number of seconds after the anchor time that the file will expire. Must be b + # + # @param anchor [Symbol, :created_at] Anchor timestamp after which the expiration policy applies. Supported anchors: ` + end end end end diff --git a/lib/openai/models/reasoning.rb b/lib/openai/models/reasoning.rb index d39b2671..f2718df3 100644 --- a/lib/openai/models/reasoning.rb +++ b/lib/openai/models/reasoning.rb @@ -37,7 +37,7 @@ class Reasoning < OpenAI::Internal::Type::BaseModel # Some parameter documentations has been truncated, see # {OpenAI::Models::Reasoning} for more details. # - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). diff --git a/lib/openai/models/responses/response.rb b/lib/openai/models/responses/response.rb index f1f341d7..76002c86 100644 --- a/lib/openai/models/responses/response.rb +++ b/lib/openai/models/responses/response.rb @@ -182,7 +182,7 @@ class Response < OpenAI::Internal::Type::BaseModel optional :prompt_cache_key, String # @!attribute reasoning - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -209,9 +209,8 @@ class Response < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -230,14 +229,9 @@ class Response < OpenAI::Internal::Type::BaseModel optional :status, enum: -> { OpenAI::Responses::ResponseStatus } # @!attribute text - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) - # - # @return [OpenAI::Models::Responses::ResponseTextConfig, nil] - optional :text, -> { OpenAI::Responses::ResponseTextConfig } + # @return [OpenAI::Models::Responses::Response::Text, nil] + optional :text, -> { OpenAI::Responses::Response::Text } # @!attribute top_logprobs # An integer between 0 and 20 specifying the number of most likely tokens to @@ -339,7 +333,7 @@ def output_text # # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi # - # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only** + # @param reasoning [OpenAI::Models::Reasoning, nil] **gpt-5 and o-series models only** # # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi # @@ -347,7 +341,7 @@ def output_text # # @param status [Symbol, OpenAI::Models::Responses::ResponseStatus] The status of the response generation. One of `completed`, `failed`, # - # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain + # @param text [OpenAI::Models::Responses::Response::Text] # # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to # @@ -458,9 +452,8 @@ module ToolChoice # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -482,6 +475,59 @@ module ServiceTier # @return [Array] end + # @see OpenAI::Models::Responses::Response#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, union: -> { OpenAI::Responses::ResponseFormatTextConfig }, api_name: :format + + # @!attribute verbosity + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @return [Symbol, OpenAI::Models::Responses::Response::Text::Verbosity, nil] + optional :verbosity, enum: -> { OpenAI::Responses::Response::Text::Verbosity }, nil?: true + + # @!method initialize(format_: nil, verbosity: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Responses::Response::Text} for more details. + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + # + # @param verbosity [Symbol, OpenAI::Models::Responses::Response::Text::Verbosity, nil] Constrains the verbosity of the model's response. Lower values will result in + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @see OpenAI::Models::Responses::Response::Text#verbosity + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW = :low + MEDIUM = :medium + HIGH = :high + + # @!method self.values + # @return [Array] + end + end + # The truncation strategy to use for the model response. # # - `auto`: If the context of this response and previous ones exceeds the model's diff --git a/lib/openai/models/responses/response_create_params.rb b/lib/openai/models/responses/response_create_params.rb index 89906f08..d7786b18 100644 --- a/lib/openai/models/responses/response_create_params.rb +++ b/lib/openai/models/responses/response_create_params.rb @@ -132,7 +132,7 @@ class ResponseCreateParams < OpenAI::Internal::Type::BaseModel optional :prompt_cache_key, String # @!attribute reasoning - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -159,9 +159,8 @@ class ResponseCreateParams < OpenAI::Internal::Type::BaseModel # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -194,8 +193,6 @@ class ResponseCreateParams < OpenAI::Internal::Type::BaseModel optional :temperature, Float, nil?: true # @!attribute text - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: # # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) @@ -307,7 +304,7 @@ class ResponseCreateParams < OpenAI::Internal::Type::BaseModel # # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi # - # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only** + # @param reasoning [OpenAI::Models::Reasoning, nil] **gpt-5 and o-series models only** # # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi # @@ -319,7 +316,7 @@ class ResponseCreateParams < OpenAI::Internal::Type::BaseModel # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # - # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain + # @param text [OpenAI::Models::Responses::ResponseCreateParams::Text] # # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceAllowed, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp, OpenAI::Models::Responses::ToolChoiceCustom] How the model should select which tool (or tools) to use when generating # @@ -367,9 +364,8 @@ module Input # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -411,6 +407,62 @@ class StreamOptions < OpenAI::Internal::Type::BaseModel # @param include_obfuscation [Boolean] When true, stream obfuscation will be enabled. Stream obfuscation adds end + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, union: -> { OpenAI::Responses::ResponseFormatTextConfig }, api_name: :format + + # @!attribute verbosity + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Text::Verbosity, nil] + optional :verbosity, + enum: -> { + OpenAI::Responses::ResponseCreateParams::Text::Verbosity + }, + nil?: true + + # @!method initialize(format_: nil, verbosity: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Responses::ResponseCreateParams::Text} for more details. + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + # + # @param verbosity [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Text::Verbosity, nil] Constrains the verbosity of the model's response. Lower values will result in + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + # + # @see OpenAI::Models::Responses::ResponseCreateParams::Text#verbosity + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW = :low + MEDIUM = :medium + HIGH = :high + + # @!method self.values + # @return [Array] + end + end + # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. diff --git a/lib/openai/models/upload_create_params.rb b/lib/openai/models/upload_create_params.rb index 54e7530f..2431059e 100644 --- a/lib/openai/models/upload_create_params.rb +++ b/lib/openai/models/upload_create_params.rb @@ -37,7 +37,14 @@ class UploadCreateParams < OpenAI::Internal::Type::BaseModel # @return [Symbol, OpenAI::Models::FilePurpose] required :purpose, enum: -> { OpenAI::FilePurpose } - # @!method initialize(bytes:, filename:, mime_type:, purpose:, request_options: {}) + # @!attribute expires_after + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + # + # @return [OpenAI::Models::UploadCreateParams::ExpiresAfter, nil] + optional :expires_after, -> { OpenAI::UploadCreateParams::ExpiresAfter } + + # @!method initialize(bytes:, filename:, mime_type:, purpose:, expires_after: nil, request_options: {}) # Some parameter documentations has been truncated, see # {OpenAI::Models::UploadCreateParams} for more details. # @@ -49,7 +56,36 @@ class UploadCreateParams < OpenAI::Internal::Type::BaseModel # # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. # + # @param expires_after [OpenAI::Models::UploadCreateParams::ExpiresAfter] The expiration policy for a file. By default, files with `purpose=batch` expire + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}] + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + # @!attribute anchor + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + # + # @return [Symbol, :created_at] + required :anchor, const: :created_at + + # @!attribute seconds + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + # + # @return [Integer] + required :seconds, Integer + + # @!method initialize(seconds:, anchor: :created_at) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::UploadCreateParams::ExpiresAfter} for more details. + # + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + # + # @param seconds [Integer] The number of seconds after the anchor time that the file will expire. Must be b + # + # @param anchor [Symbol, :created_at] Anchor timestamp after which the expiration policy applies. Supported anchors: ` + end end end end diff --git a/lib/openai/resources/batches.rb b/lib/openai/resources/batches.rb index bdd8d876..bd8f7530 100644 --- a/lib/openai/resources/batches.rb +++ b/lib/openai/resources/batches.rb @@ -8,7 +8,7 @@ class Batches # # Creates and executes a batch from an uploaded file of requests # - # @overload create(completion_window:, endpoint:, input_file_id:, metadata: nil, request_options: {}) + # @overload create(completion_window:, endpoint:, input_file_id:, metadata: nil, output_expires_after: nil, request_options: {}) # # @param completion_window [Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow] The time frame within which the batch should be processed. Currently only `24h` # @@ -18,6 +18,8 @@ class Batches # # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be # + # @param output_expires_after [OpenAI::Models::BatchCreateParams::OutputExpiresAfter] The expiration policy for the output and/or error file that are generated for a + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [OpenAI::Models::Batch] diff --git a/lib/openai/resources/chat/completions.rb b/lib/openai/resources/chat/completions.rb index a3518b48..6b08d9c4 100644 --- a/lib/openai/resources/chat/completions.rb +++ b/lib/openai/resources/chat/completions.rb @@ -30,7 +30,7 @@ class Completions # unsupported parameters in reasoning models, # [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning). # - # @overload create(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) + # @overload create(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) # # @param messages [Array] A list of messages comprising the conversation so far. Depending on the # @@ -84,6 +84,8 @@ class Completions # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # + # @param text [OpenAI::Models::Chat::CompletionCreateParams::Text] + # # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionAllowedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoiceCustom] Controls which (if any) tool is called by the model. # # @param tools [Array] A list of tools the model may call. You can provide either @@ -234,7 +236,7 @@ def stream # unsupported parameters in reasoning models, # [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning). # - # @overload stream_raw(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) + # @overload stream_raw(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, verbosity: nil, web_search_options: nil, request_options: {}) # # @param messages [Array] A list of messages comprising the conversation so far. Depending on the # @@ -288,6 +290,8 @@ def stream # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # + # @param text [OpenAI::Models::Chat::CompletionCreateParams::Text] + # # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionAllowedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoice, OpenAI::Models::Chat::ChatCompletionNamedToolChoiceCustom] Controls which (if any) tool is called by the model. # # @param tools [Array] A list of tools the model may call. You can provide either diff --git a/lib/openai/resources/files.rb b/lib/openai/resources/files.rb index 34eccf82..52d9a808 100644 --- a/lib/openai/resources/files.rb +++ b/lib/openai/resources/files.rb @@ -8,7 +8,7 @@ class Files # # Upload a file that can be used across various endpoints. Individual files can be # up to 512 MB, and the size of all files uploaded by one organization can be up - # to 100 GB. + # to 1 TB. # # The Assistants API supports files up to 2 million tokens and of specific file # types. See the @@ -28,12 +28,14 @@ class Files # Please [contact us](https://help.openai.com/) if you need to increase these # storage limits. # - # @overload create(file:, purpose:, request_options: {}) + # @overload create(file:, purpose:, expires_after: nil, request_options: {}) # # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded. # # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. One of: - `assistants`: Used in the A # + # @param expires_after [OpenAI::Models::FileCreateParams::ExpiresAfter] The expiration policy for a file. By default, files with `purpose=batch` expire + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [OpenAI::Models::FileObject] diff --git a/lib/openai/resources/responses.rb b/lib/openai/resources/responses.rb index 5f6b353b..e6f7e4ef 100644 --- a/lib/openai/resources/responses.rb +++ b/lib/openai/resources/responses.rb @@ -49,7 +49,7 @@ class Responses # # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi # - # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only** + # @param reasoning [OpenAI::Models::Reasoning, nil] **gpt-5 and o-series models only** # # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi # @@ -61,7 +61,7 @@ class Responses # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # - # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain + # @param text [OpenAI::Models::Responses::ResponseCreateParams::Text] # # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceAllowed, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp, OpenAI::Models::Responses::ToolChoiceCustom] How the model should select which tool (or tools) to use when generating # @@ -264,7 +264,7 @@ def stream(params) # # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi # - # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only** + # @param reasoning [OpenAI::Models::Reasoning, nil] **gpt-5 and o-series models only** # # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi # @@ -276,7 +276,7 @@ def stream(params) # # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m # - # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain + # @param text [OpenAI::Models::Responses::ResponseCreateParams::Text] # # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceAllowed, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp, OpenAI::Models::Responses::ToolChoiceCustom] How the model should select which tool (or tools) to use when generating # diff --git a/lib/openai/resources/uploads.rb b/lib/openai/resources/uploads.rb index 65d75883..b9037fd9 100644 --- a/lib/openai/resources/uploads.rb +++ b/lib/openai/resources/uploads.rb @@ -29,7 +29,7 @@ class Uploads # the documentation on # [creating a File](https://platform.openai.com/docs/api-reference/files/create). # - # @overload create(bytes:, filename:, mime_type:, purpose:, request_options: {}) + # @overload create(bytes:, filename:, mime_type:, purpose:, expires_after: nil, request_options: {}) # # @param bytes [Integer] The number of bytes in the file you are uploading. # @@ -39,6 +39,8 @@ class Uploads # # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. # + # @param expires_after [OpenAI::Models::UploadCreateParams::ExpiresAfter] The expiration policy for a file. By default, files with `purpose=batch` expire + # # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] # # @return [OpenAI::Models::Upload] diff --git a/rbi/openai/models/batch_create_params.rbi b/rbi/openai/models/batch_create_params.rbi index 7568daed..c15c791a 100644 --- a/rbi/openai/models/batch_create_params.rbi +++ b/rbi/openai/models/batch_create_params.rbi @@ -44,6 +44,19 @@ module OpenAI sig { returns(T.nilable(T::Hash[Symbol, String])) } attr_accessor :metadata + # The expiration policy for the output and/or error file that are generated for a + # batch. + sig { returns(T.nilable(OpenAI::BatchCreateParams::OutputExpiresAfter)) } + attr_reader :output_expires_after + + sig do + params( + output_expires_after: + OpenAI::BatchCreateParams::OutputExpiresAfter::OrHash + ).void + end + attr_writer :output_expires_after + sig do params( completion_window: @@ -51,6 +64,8 @@ module OpenAI endpoint: OpenAI::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, metadata: T.nilable(T::Hash[Symbol, String]), + output_expires_after: + OpenAI::BatchCreateParams::OutputExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(T.attached_class) end @@ -80,6 +95,9 @@ module OpenAI # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. metadata: nil, + # The expiration policy for the output and/or error file that are generated for a + # batch. + output_expires_after: nil, request_options: {} ) end @@ -92,6 +110,7 @@ module OpenAI endpoint: OpenAI::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, metadata: T.nilable(T::Hash[Symbol, String]), + output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter, request_options: OpenAI::RequestOptions } ) @@ -165,6 +184,47 @@ module OpenAI def self.values end end + + class OutputExpiresAfter < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::BatchCreateParams::OutputExpiresAfter, + OpenAI::Internal::AnyHash + ) + end + + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. Note that the anchor is the file creation time, not the time the + # batch is created. + sig { returns(Symbol) } + attr_accessor :anchor + + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + sig { returns(Integer) } + attr_accessor :seconds + + # The expiration policy for the output and/or error file that are generated for a + # batch. + sig do + params(seconds: Integer, anchor: Symbol).returns(T.attached_class) + end + def self.new( + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + seconds:, + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. Note that the anchor is the file creation time, not the time the + # batch is created. + anchor: :created_at + ) + end + + sig { override.returns({ anchor: Symbol, seconds: Integer }) } + def to_hash + end + end end end end diff --git a/rbi/openai/models/beta/thread_create_and_run_params.rbi b/rbi/openai/models/beta/thread_create_and_run_params.rbi index 2a603dd6..31e4023d 100644 --- a/rbi/openai/models/beta/thread_create_and_run_params.rbi +++ b/rbi/openai/models/beta/thread_create_and_run_params.rbi @@ -187,7 +187,7 @@ module OpenAI attr_accessor :top_p # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do returns( T.nilable( @@ -343,7 +343,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. truncation_strategy: nil, request_options: {} ) @@ -1459,7 +1459,7 @@ module OpenAI attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do params( type: diff --git a/rbi/openai/models/beta/threads/run.rbi b/rbi/openai/models/beta/threads/run.rbi index 7940c801..1f45da92 100644 --- a/rbi/openai/models/beta/threads/run.rbi +++ b/rbi/openai/models/beta/threads/run.rbi @@ -184,7 +184,7 @@ module OpenAI attr_accessor :tools # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do returns(T.nilable(OpenAI::Beta::Threads::Run::TruncationStrategy)) end @@ -375,7 +375,7 @@ module OpenAI # this run. tools:, # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. truncation_strategy:, # Usage statistics related to the run. This value will be `null` if the run is not # in a terminal state (i.e. `in_progress`, `queued`, etc.). @@ -740,7 +740,7 @@ module OpenAI attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do params( type: diff --git a/rbi/openai/models/beta/threads/run_create_params.rbi b/rbi/openai/models/beta/threads/run_create_params.rbi index 04d643a2..ccb3b696 100644 --- a/rbi/openai/models/beta/threads/run_create_params.rbi +++ b/rbi/openai/models/beta/threads/run_create_params.rbi @@ -204,7 +204,7 @@ module OpenAI attr_accessor :top_p # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do returns( T.nilable( @@ -378,7 +378,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. truncation_strategy: nil, request_options: {} ) @@ -803,7 +803,7 @@ module OpenAI attr_accessor :last_messages # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. sig do params( type: diff --git a/rbi/openai/models/chat/chat_completion.rbi b/rbi/openai/models/chat/chat_completion.rbi index 61f4d426..c29271e7 100644 --- a/rbi/openai/models/chat/chat_completion.rbi +++ b/rbi/openai/models/chat/chat_completion.rbi @@ -40,9 +40,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -106,9 +105,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -371,9 +369,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the diff --git a/rbi/openai/models/chat/chat_completion_chunk.rbi b/rbi/openai/models/chat/chat_completion_chunk.rbi index 7865525a..f309f2e3 100644 --- a/rbi/openai/models/chat/chat_completion_chunk.rbi +++ b/rbi/openai/models/chat/chat_completion_chunk.rbi @@ -42,9 +42,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -121,9 +120,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -791,9 +789,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the diff --git a/rbi/openai/models/chat/completion_create_params.rbi b/rbi/openai/models/chat/completion_create_params.rbi index edbf9656..b8f9aef5 100644 --- a/rbi/openai/models/chat/completion_create_params.rbi +++ b/rbi/openai/models/chat/completion_create_params.rbi @@ -297,9 +297,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -353,6 +352,14 @@ module OpenAI sig { returns(T.nilable(Float)) } attr_accessor :temperature + sig { returns(T.nilable(OpenAI::Chat::CompletionCreateParams::Text)) } + attr_reader :text + + sig do + params(text: OpenAI::Chat::CompletionCreateParams::Text::OrHash).void + end + attr_writer :text + # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can # pick between generating a message or calling one or more tools. `required` means @@ -533,6 +540,7 @@ module OpenAI stream_options: T.nilable(OpenAI::Chat::ChatCompletionStreamOptions::OrHash), temperature: T.nilable(Float), + text: OpenAI::Chat::CompletionCreateParams::Text::OrHash, tool_choice: T.any( OpenAI::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, @@ -700,9 +708,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -728,6 +735,7 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, + text: nil, # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can # pick between generating a message or calling one or more tools. `required` means @@ -830,6 +838,7 @@ module OpenAI stream_options: T.nilable(OpenAI::Chat::ChatCompletionStreamOptions), temperature: T.nilable(Float), + text: OpenAI::Chat::CompletionCreateParams::Text, tool_choice: T.any( OpenAI::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, @@ -1100,9 +1109,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -1179,6 +1187,99 @@ module OpenAI ) end + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Chat::CompletionCreateParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + sig do + returns( + T.nilable( + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::OrSymbol + ) + ) + end + attr_accessor :verbosity + + sig do + params( + verbosity: + T.nilable( + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::OrSymbol + ) + ).returns(T.attached_class) + end + def self.new( + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + verbosity: nil + ) + end + + sig do + override.returns( + { + verbosity: + T.nilable( + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::OrSymbol + ) + } + ) + end + def to_hash + end + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + module Verbosity + extend OpenAI::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + OpenAI::Chat::CompletionCreateParams::Text::Verbosity + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LOW = + T.let( + :low, + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::TaggedSymbol + ) + MEDIUM = + T.let( + :medium, + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::TaggedSymbol + ) + HIGH = + T.let( + :high, + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + OpenAI::Chat::CompletionCreateParams::Text::Verbosity::TaggedSymbol + ] + ) + end + def self.values + end + end + end + # Constrains the verbosity of the model's response. Lower values will result in # more concise responses, while higher values will result in more verbose # responses. Currently supported values are `low`, `medium`, and `high`. diff --git a/rbi/openai/models/file_create_params.rbi b/rbi/openai/models/file_create_params.rbi index 493d915c..ef0c24d4 100644 --- a/rbi/openai/models/file_create_params.rbi +++ b/rbi/openai/models/file_create_params.rbi @@ -22,10 +22,23 @@ module OpenAI sig { returns(OpenAI::FilePurpose::OrSymbol) } attr_accessor :purpose + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + sig { returns(T.nilable(OpenAI::FileCreateParams::ExpiresAfter)) } + attr_reader :expires_after + + sig do + params( + expires_after: OpenAI::FileCreateParams::ExpiresAfter::OrHash + ).void + end + attr_writer :expires_after + sig do params( file: OpenAI::Internal::FileInput, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::FileCreateParams::ExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(T.attached_class) end @@ -37,6 +50,9 @@ module OpenAI # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: # Flexible file type for any purpose - `evals`: Used for eval data sets purpose:, + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + expires_after: nil, request_options: {} ) end @@ -46,12 +62,52 @@ module OpenAI { file: OpenAI::Internal::FileInput, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::FileCreateParams::ExpiresAfter, request_options: OpenAI::RequestOptions } ) end def to_hash end + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::FileCreateParams::ExpiresAfter, + OpenAI::Internal::AnyHash + ) + end + + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + sig { returns(Symbol) } + attr_accessor :anchor + + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + sig { returns(Integer) } + attr_accessor :seconds + + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + sig do + params(seconds: Integer, anchor: Symbol).returns(T.attached_class) + end + def self.new( + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + seconds:, + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + anchor: :created_at + ) + end + + sig { override.returns({ anchor: Symbol, seconds: Integer }) } + def to_hash + end + end end end end diff --git a/rbi/openai/models/reasoning.rbi b/rbi/openai/models/reasoning.rbi index 5243471d..f6364147 100644 --- a/rbi/openai/models/reasoning.rbi +++ b/rbi/openai/models/reasoning.rbi @@ -28,7 +28,7 @@ module OpenAI sig { returns(T.nilable(OpenAI::Reasoning::Summary::OrSymbol)) } attr_accessor :summary - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). diff --git a/rbi/openai/models/responses/response.rbi b/rbi/openai/models/responses/response.rbi index 8980d26b..8a36dab9 100644 --- a/rbi/openai/models/responses/response.rbi +++ b/rbi/openai/models/responses/response.rbi @@ -176,7 +176,7 @@ module OpenAI sig { params(prompt_cache_key: String).void } attr_writer :prompt_cache_key - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -205,9 +205,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -231,15 +230,10 @@ module OpenAI sig { params(status: OpenAI::Responses::ResponseStatus::OrSymbol).void } attr_writer :status - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) - sig { returns(T.nilable(OpenAI::Responses::ResponseTextConfig)) } + sig { returns(T.nilable(OpenAI::Responses::Response::Text)) } attr_reader :text - sig { params(text: OpenAI::Responses::ResponseTextConfig::OrHash).void } + sig { params(text: OpenAI::Responses::Response::Text::OrHash).void } attr_writer :text # An integer between 0 and 20 specifying the number of most likely tokens to @@ -351,7 +345,7 @@ module OpenAI service_tier: T.nilable(OpenAI::Responses::Response::ServiceTier::OrSymbol), status: OpenAI::Responses::ResponseStatus::OrSymbol, - text: OpenAI::Responses::ResponseTextConfig::OrHash, + text: OpenAI::Responses::Response::Text::OrHash, top_logprobs: T.nilable(Integer), truncation: T.nilable(OpenAI::Responses::Response::Truncation::OrSymbol), @@ -453,7 +447,7 @@ module OpenAI # hit rates. Replaces the `user` field. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching). prompt_cache_key: nil, - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -472,9 +466,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -485,11 +478,6 @@ module OpenAI # The status of the response generation. One of `completed`, `failed`, # `in_progress`, `cancelled`, `queued`, or `incomplete`. status: nil, - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) text: nil, # An integer between 0 and 20 specifying the number of most likely tokens to # return at each token position, each with an associated log probability. @@ -548,7 +536,7 @@ module OpenAI OpenAI::Responses::Response::ServiceTier::TaggedSymbol ), status: OpenAI::Responses::ResponseStatus::TaggedSymbol, - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::Response::Text, top_logprobs: T.nilable(Integer), truncation: T.nilable( @@ -717,9 +705,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -764,6 +751,149 @@ module OpenAI end end + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Responses::Response::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable(OpenAI::Responses::ResponseFormatTextConfig::Variants) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + sig do + returns( + T.nilable( + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ) + ) + end + attr_accessor :verbosity + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ), + verbosity: + T.nilable( + OpenAI::Responses::Response::Text::Verbosity::OrSymbol + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil, + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + verbosity: nil + ) + end + + sig do + override.returns( + { + format_: OpenAI::Responses::ResponseFormatTextConfig::Variants, + verbosity: + T.nilable( + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ) + } + ) + end + def to_hash + end + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + module Verbosity + extend OpenAI::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, OpenAI::Responses::Response::Text::Verbosity) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LOW = + T.let( + :low, + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ) + MEDIUM = + T.let( + :medium, + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ) + HIGH = + T.let( + :high, + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + OpenAI::Responses::Response::Text::Verbosity::TaggedSymbol + ] + ) + end + def self.values + end + end + end + # The truncation strategy to use for the model response. # # - `auto`: If the context of this response and previous ones exceeds the model's diff --git a/rbi/openai/models/responses/response_create_params.rbi b/rbi/openai/models/responses/response_create_params.rbi index ad7a9dc9..9ff76fa1 100644 --- a/rbi/openai/models/responses/response_create_params.rbi +++ b/rbi/openai/models/responses/response_create_params.rbi @@ -157,7 +157,7 @@ module OpenAI sig { params(prompt_cache_key: String).void } attr_writer :prompt_cache_key - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -186,9 +186,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -233,12 +232,9 @@ module OpenAI sig { returns(T.nilable(Float)) } attr_accessor :temperature - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) - sig { returns(T.nilable(OpenAI::Responses::ResponseTextConfig)) } + sig do + returns(T.nilable(OpenAI::Responses::ResponseCreateParams::Text)) + end attr_reader :text sig do @@ -417,7 +413,7 @@ module OpenAI OpenAI::Responses::ResponseCreateParams::StreamOptions::OrHash ), temperature: T.nilable(Float), - text: OpenAI::Responses::ResponseTextConfig::OrHash, + text: OpenAI::Responses::ResponseCreateParams::Text::OrHash, tool_choice: T.any( OpenAI::Responses::ToolChoiceOptions::OrSymbol, @@ -523,7 +519,7 @@ module OpenAI # hit rates. Replaces the `user` field. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching). prompt_cache_key: nil, - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -542,9 +538,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -561,11 +556,6 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) text: nil, # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model @@ -650,7 +640,7 @@ module OpenAI OpenAI::Responses::ResponseCreateParams::StreamOptions ), temperature: T.nilable(Float), - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::ResponseCreateParams::Text, tool_choice: T.any( OpenAI::Responses::ToolChoiceOptions::OrSymbol, @@ -725,9 +715,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -824,6 +813,163 @@ module OpenAI end end + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Responses::ResponseCreateParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + T.any( + OpenAI::ResponseFormatText, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig, + OpenAI::ResponseFormatJSONObject + ) + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::OrSymbol + ) + ) + end + attr_accessor :verbosity + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ), + verbosity: + T.nilable( + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::OrSymbol + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil, + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + verbosity: nil + ) + end + + sig do + override.returns( + { + format_: + T.any( + OpenAI::ResponseFormatText, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig, + OpenAI::ResponseFormatJSONObject + ), + verbosity: + T.nilable( + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::OrSymbol + ) + } + ) + end + def to_hash + end + + # Constrains the verbosity of the model's response. Lower values will result in + # more concise responses, while higher values will result in more verbose + # responses. Currently supported values are `low`, `medium`, and `high`. + module Verbosity + extend OpenAI::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + OpenAI::Responses::ResponseCreateParams::Text::Verbosity + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LOW = + T.let( + :low, + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::TaggedSymbol + ) + MEDIUM = + T.let( + :medium, + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::TaggedSymbol + ) + HIGH = + T.let( + :high, + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseCreateParams::Text::Verbosity::TaggedSymbol + ] + ) + end + def self.values + end + end + end + # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model # can call. diff --git a/rbi/openai/models/upload_create_params.rbi b/rbi/openai/models/upload_create_params.rbi index d7e3500c..63349340 100644 --- a/rbi/openai/models/upload_create_params.rbi +++ b/rbi/openai/models/upload_create_params.rbi @@ -33,12 +33,25 @@ module OpenAI sig { returns(OpenAI::FilePurpose::OrSymbol) } attr_accessor :purpose + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + sig { returns(T.nilable(OpenAI::UploadCreateParams::ExpiresAfter)) } + attr_reader :expires_after + + sig do + params( + expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash + ).void + end + attr_writer :expires_after + sig do params( bytes: Integer, filename: String, mime_type: String, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(T.attached_class) end @@ -57,6 +70,9 @@ module OpenAI # See the # [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose). purpose:, + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + expires_after: nil, request_options: {} ) end @@ -68,12 +84,52 @@ module OpenAI filename: String, mime_type: String, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::UploadCreateParams::ExpiresAfter, request_options: OpenAI::RequestOptions } ) end def to_hash end + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::UploadCreateParams::ExpiresAfter, + OpenAI::Internal::AnyHash + ) + end + + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + sig { returns(Symbol) } + attr_accessor :anchor + + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + sig { returns(Integer) } + attr_accessor :seconds + + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + sig do + params(seconds: Integer, anchor: Symbol).returns(T.attached_class) + end + def self.new( + # The number of seconds after the anchor time that the file will expire. Must be + # between 3600 (1 hour) and 2592000 (30 days). + seconds:, + # Anchor timestamp after which the expiration policy applies. Supported anchors: + # `created_at`. + anchor: :created_at + ) + end + + sig { override.returns({ anchor: Symbol, seconds: Integer }) } + def to_hash + end + end end end end diff --git a/rbi/openai/resources/batches.rbi b/rbi/openai/resources/batches.rbi index 64125755..26543c2d 100644 --- a/rbi/openai/resources/batches.rbi +++ b/rbi/openai/resources/batches.rbi @@ -11,6 +11,8 @@ module OpenAI endpoint: OpenAI::BatchCreateParams::Endpoint::OrSymbol, input_file_id: String, metadata: T.nilable(T::Hash[Symbol, String]), + output_expires_after: + OpenAI::BatchCreateParams::OutputExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(OpenAI::Batch) end @@ -40,6 +42,9 @@ module OpenAI # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. metadata: nil, + # The expiration policy for the output and/or error file that are generated for a + # batch. + output_expires_after: nil, request_options: {} ) end diff --git a/rbi/openai/resources/beta/threads.rbi b/rbi/openai/resources/beta/threads.rbi index 738bcf29..9efef885 100644 --- a/rbi/openai/resources/beta/threads.rbi +++ b/rbi/openai/resources/beta/threads.rbi @@ -242,7 +242,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. truncation_strategy: nil, # There is no need to provide `stream:`. Instead, use `#stream_raw` or # `#create_and_run` for streaming and non-streaming use cases, respectively. @@ -396,7 +396,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Controls for how a thread will be truncated prior to the run. Use this to - # control the intial context window of the run. + # control the initial context window of the run. truncation_strategy: nil, # There is no need to provide `stream:`. Instead, use `#stream_raw` or # `#create_and_run` for streaming and non-streaming use cases, respectively. diff --git a/rbi/openai/resources/beta/threads/runs.rbi b/rbi/openai/resources/beta/threads/runs.rbi index bab46d8b..d6e83222 100644 --- a/rbi/openai/resources/beta/threads/runs.rbi +++ b/rbi/openai/resources/beta/threads/runs.rbi @@ -174,7 +174,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Body param: Controls for how a thread will be truncated prior to the run. Use - # this to control the intial context window of the run. + # this to control the initial context window of the run. truncation_strategy: nil, # There is no need to provide `stream:`. Instead, use `#create_stream_raw` or # `#create` for streaming and non-streaming use cases, respectively. @@ -353,7 +353,7 @@ module OpenAI # We generally recommend altering this or temperature but not both. top_p: nil, # Body param: Controls for how a thread will be truncated prior to the run. Use - # this to control the intial context window of the run. + # this to control the initial context window of the run. truncation_strategy: nil, # There is no need to provide `stream:`. Instead, use `#create_stream_raw` or # `#create` for streaming and non-streaming use cases, respectively. diff --git a/rbi/openai/resources/chat/completions.rbi b/rbi/openai/resources/chat/completions.rbi index 3dfda2d3..bd3b6845 100644 --- a/rbi/openai/resources/chat/completions.rbi +++ b/rbi/openai/resources/chat/completions.rbi @@ -86,6 +86,7 @@ module OpenAI stream_options: T.nilable(OpenAI::Chat::ChatCompletionStreamOptions::OrHash), temperature: T.nilable(Float), + text: OpenAI::Chat::CompletionCreateParams::Text::OrHash, tool_choice: T.any( OpenAI::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, @@ -254,9 +255,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -282,6 +282,7 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, + text: nil, # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can # pick between generating a message or calling one or more tools. `required` means @@ -405,6 +406,7 @@ module OpenAI stream_options: T.nilable(OpenAI::Chat::ChatCompletionStreamOptions::OrHash), temperature: T.nilable(Float), + text: OpenAI::Chat::CompletionCreateParams::Text::OrHash, tool_choice: T.any( OpenAI::Chat::ChatCompletionToolChoiceOption::Auto::OrSymbol, @@ -572,9 +574,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -600,6 +601,7 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, + text: nil, # Controls which (if any) tool is called by the model. `none` means the model will # not call any tool and instead generates a message. `auto` means the model can # pick between generating a message or calling one or more tools. `required` means diff --git a/rbi/openai/resources/files.rbi b/rbi/openai/resources/files.rbi index 9ac9665f..0b28857e 100644 --- a/rbi/openai/resources/files.rbi +++ b/rbi/openai/resources/files.rbi @@ -5,7 +5,7 @@ module OpenAI class Files # Upload a file that can be used across various endpoints. Individual files can be # up to 512 MB, and the size of all files uploaded by one organization can be up - # to 100 GB. + # to 1 TB. # # The Assistants API supports files up to 2 million tokens and of specific file # types. See the @@ -28,6 +28,7 @@ module OpenAI params( file: OpenAI::Internal::FileInput, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::FileCreateParams::ExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(OpenAI::FileObject) end @@ -39,6 +40,9 @@ module OpenAI # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: # Flexible file type for any purpose - `evals`: Used for eval data sets purpose:, + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + expires_after: nil, request_options: {} ) end diff --git a/rbi/openai/resources/responses.rbi b/rbi/openai/resources/responses.rbi index 7a2577b3..de0f3a49 100644 --- a/rbi/openai/resources/responses.rbi +++ b/rbi/openai/resources/responses.rbi @@ -164,7 +164,7 @@ module OpenAI # hit rates. Replaces the `user` field. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching). prompt_cache_key: nil, - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -183,9 +183,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -202,11 +201,6 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) text: nil, # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model @@ -423,7 +417,7 @@ module OpenAI # hit rates. Replaces the `user` field. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching). prompt_cache_key: nil, - # **o-series models only** + # **gpt-5 and o-series models only** # # Configuration options for # [reasoning models](https://platform.openai.com/docs/guides/reasoning). @@ -442,9 +436,8 @@ module OpenAI # - If set to 'default', then the request will be processed with the standard # pricing and performance for the selected model. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or - # 'priority', then the request will be processed with the corresponding service - # tier. [Contact sales](https://openai.com/contact-sales) to learn more about - # Priority processing. + # '[priority](https://openai.com/api-priority-processing/)', then the request + # will be processed with the corresponding service tier. # - When not set, the default behavior is 'auto'. # # When the `service_tier` parameter is set, the response body will include the @@ -461,11 +454,6 @@ module OpenAI # focused and deterministic. We generally recommend altering this or `top_p` but # not both. temperature: nil, - # Configuration options for a text response from the model. Can be plain text or - # structured JSON data. Learn more: - # - # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text) - # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) text: nil, # How the model should select which tool (or tools) to use when generating a # response. See the `tools` parameter to see how to specify which tools the model diff --git a/rbi/openai/resources/uploads.rbi b/rbi/openai/resources/uploads.rbi index eef3396f..1a0f93c2 100644 --- a/rbi/openai/resources/uploads.rbi +++ b/rbi/openai/resources/uploads.rbi @@ -31,6 +31,7 @@ module OpenAI filename: String, mime_type: String, purpose: OpenAI::FilePurpose::OrSymbol, + expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash, request_options: OpenAI::RequestOptions::OrHash ).returns(OpenAI::Upload) end @@ -49,6 +50,9 @@ module OpenAI # See the # [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose). purpose:, + # The expiration policy for a file. By default, files with `purpose=batch` expire + # after 30 days and all other files are persisted until they are manually deleted. + expires_after: nil, request_options: {} ) end diff --git a/sig/openai/models/batch_create_params.rbs b/sig/openai/models/batch_create_params.rbs index 85193e35..3b5ff7a8 100644 --- a/sig/openai/models/batch_create_params.rbs +++ b/sig/openai/models/batch_create_params.rbs @@ -5,7 +5,8 @@ module OpenAI completion_window: OpenAI::Models::BatchCreateParams::completion_window, endpoint: OpenAI::Models::BatchCreateParams::endpoint, input_file_id: String, - metadata: OpenAI::Models::metadata? + metadata: OpenAI::Models::metadata?, + output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter } & OpenAI::Internal::Type::request_parameters @@ -21,11 +22,18 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? + attr_reader output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter? + + def output_expires_after=: ( + OpenAI::BatchCreateParams::OutputExpiresAfter + ) -> OpenAI::BatchCreateParams::OutputExpiresAfter + def initialize: ( completion_window: OpenAI::Models::BatchCreateParams::completion_window, endpoint: OpenAI::Models::BatchCreateParams::endpoint, input_file_id: String, ?metadata: OpenAI::Models::metadata?, + ?output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter, ?request_options: OpenAI::request_opts ) -> void @@ -34,6 +42,7 @@ module OpenAI endpoint: OpenAI::Models::BatchCreateParams::endpoint, input_file_id: String, metadata: OpenAI::Models::metadata?, + output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter, request_options: OpenAI::RequestOptions } @@ -63,6 +72,18 @@ module OpenAI def self?.values: -> ::Array[OpenAI::Models::BatchCreateParams::endpoint] end + + type output_expires_after = { anchor: :created_at, seconds: Integer } + + class OutputExpiresAfter < OpenAI::Internal::Type::BaseModel + attr_accessor anchor: :created_at + + attr_accessor seconds: Integer + + def initialize: (seconds: Integer, ?anchor: :created_at) -> void + + def to_hash: -> { anchor: :created_at, seconds: Integer } + end end end end diff --git a/sig/openai/models/chat/completion_create_params.rbs b/sig/openai/models/chat/completion_create_params.rbs index e02095c4..d6328830 100644 --- a/sig/openai/models/chat/completion_create_params.rbs +++ b/sig/openai/models/chat/completion_create_params.rbs @@ -29,6 +29,7 @@ module OpenAI store: bool?, stream_options: OpenAI::Chat::ChatCompletionStreamOptions?, temperature: Float?, + text: OpenAI::Chat::CompletionCreateParams::Text, tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, tools: ::Array[OpenAI::Models::Chat::chat_completion_tool], top_logprobs: Integer?, @@ -113,6 +114,12 @@ module OpenAI attr_accessor temperature: Float? + attr_reader text: OpenAI::Chat::CompletionCreateParams::Text? + + def text=: ( + OpenAI::Chat::CompletionCreateParams::Text + ) -> OpenAI::Chat::CompletionCreateParams::Text + attr_reader tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option? def tool_choice=: ( @@ -168,6 +175,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Chat::ChatCompletionStreamOptions?, ?temperature: Float?, + ?text: OpenAI::Chat::CompletionCreateParams::Text, ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, ?tools: ::Array[OpenAI::Models::Chat::chat_completion_tool], ?top_logprobs: Integer?, @@ -205,6 +213,7 @@ module OpenAI store: bool?, stream_options: OpenAI::Chat::ChatCompletionStreamOptions?, temperature: Float?, + text: OpenAI::Chat::CompletionCreateParams::Text, tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, tools: ::Array[OpenAI::Models::Chat::chat_completion_tool], top_logprobs: Integer?, @@ -323,6 +332,35 @@ module OpenAI StringArray: OpenAI::Internal::Type::Converter end + type text = + { + verbosity: OpenAI::Models::Chat::CompletionCreateParams::Text::verbosity? + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_accessor verbosity: OpenAI::Models::Chat::CompletionCreateParams::Text::verbosity? + + def initialize: ( + ?verbosity: OpenAI::Models::Chat::CompletionCreateParams::Text::verbosity? + ) -> void + + def to_hash: -> { + verbosity: OpenAI::Models::Chat::CompletionCreateParams::Text::verbosity? + } + + type verbosity = :low | :medium | :high + + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW: :low + MEDIUM: :medium + HIGH: :high + + def self?.values: -> ::Array[OpenAI::Models::Chat::CompletionCreateParams::Text::verbosity] + end + end + type verbosity = :low | :medium | :high module Verbosity diff --git a/sig/openai/models/file_create_params.rbs b/sig/openai/models/file_create_params.rbs index 2abf1615..90ff00c6 100644 --- a/sig/openai/models/file_create_params.rbs +++ b/sig/openai/models/file_create_params.rbs @@ -3,7 +3,8 @@ module OpenAI type file_create_params = { file: OpenAI::Internal::file_input, - purpose: OpenAI::Models::file_purpose + purpose: OpenAI::Models::file_purpose, + expires_after: OpenAI::FileCreateParams::ExpiresAfter } & OpenAI::Internal::Type::request_parameters @@ -15,17 +16,37 @@ module OpenAI attr_accessor purpose: OpenAI::Models::file_purpose + attr_reader expires_after: OpenAI::FileCreateParams::ExpiresAfter? + + def expires_after=: ( + OpenAI::FileCreateParams::ExpiresAfter + ) -> OpenAI::FileCreateParams::ExpiresAfter + def initialize: ( file: OpenAI::Internal::file_input, purpose: OpenAI::Models::file_purpose, + ?expires_after: OpenAI::FileCreateParams::ExpiresAfter, ?request_options: OpenAI::request_opts ) -> void def to_hash: -> { file: OpenAI::Internal::file_input, purpose: OpenAI::Models::file_purpose, + expires_after: OpenAI::FileCreateParams::ExpiresAfter, request_options: OpenAI::RequestOptions } + + type expires_after = { anchor: :created_at, seconds: Integer } + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + attr_accessor anchor: :created_at + + attr_accessor seconds: Integer + + def initialize: (seconds: Integer, ?anchor: :created_at) -> void + + def to_hash: -> { anchor: :created_at, seconds: Integer } + end end end end diff --git a/sig/openai/models/responses/response.rbs b/sig/openai/models/responses/response.rbs index 6bf78a3c..34a35148 100644 --- a/sig/openai/models/responses/response.rbs +++ b/sig/openai/models/responses/response.rbs @@ -27,7 +27,7 @@ module OpenAI safety_identifier: String, service_tier: OpenAI::Models::Responses::Response::service_tier?, status: OpenAI::Models::Responses::response_status, - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::Response::Text, top_logprobs: Integer?, truncation: OpenAI::Models::Responses::Response::truncation?, usage: OpenAI::Responses::ResponseUsage, @@ -91,11 +91,11 @@ module OpenAI OpenAI::Models::Responses::response_status ) -> OpenAI::Models::Responses::response_status - attr_reader text: OpenAI::Responses::ResponseTextConfig? + attr_reader text: OpenAI::Responses::Response::Text? def text=: ( - OpenAI::Responses::ResponseTextConfig - ) -> OpenAI::Responses::ResponseTextConfig + OpenAI::Responses::Response::Text + ) -> OpenAI::Responses::Response::Text attr_accessor top_logprobs: Integer? @@ -135,7 +135,7 @@ module OpenAI ?safety_identifier: String, ?service_tier: OpenAI::Models::Responses::Response::service_tier?, ?status: OpenAI::Models::Responses::response_status, - ?text: OpenAI::Responses::ResponseTextConfig, + ?text: OpenAI::Responses::Response::Text, ?top_logprobs: Integer?, ?truncation: OpenAI::Models::Responses::Response::truncation?, ?usage: OpenAI::Responses::ResponseUsage, @@ -168,7 +168,7 @@ module OpenAI safety_identifier: String, service_tier: OpenAI::Models::Responses::Response::service_tier?, status: OpenAI::Models::Responses::response_status, - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::Response::Text, top_logprobs: Integer?, truncation: OpenAI::Models::Responses::Response::truncation?, usage: OpenAI::Responses::ResponseUsage, @@ -246,6 +246,44 @@ module OpenAI def self?.values: -> ::Array[OpenAI::Models::Responses::Response::service_tier] end + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config, + verbosity: OpenAI::Models::Responses::Response::Text::verbosity? + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + attr_accessor verbosity: OpenAI::Models::Responses::Response::Text::verbosity? + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config, + ?verbosity: OpenAI::Models::Responses::Response::Text::verbosity? + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config, + verbosity: OpenAI::Models::Responses::Response::Text::verbosity? + } + + type verbosity = :low | :medium | :high + + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW: :low + MEDIUM: :medium + HIGH: :high + + def self?.values: -> ::Array[OpenAI::Models::Responses::Response::Text::verbosity] + end + end + type truncation = :auto | :disabled module Truncation diff --git a/sig/openai/models/responses/response_create_params.rbs b/sig/openai/models/responses/response_create_params.rbs index 83f641b4..9abee74d 100644 --- a/sig/openai/models/responses/response_create_params.rbs +++ b/sig/openai/models/responses/response_create_params.rbs @@ -21,7 +21,7 @@ module OpenAI store: bool?, stream_options: OpenAI::Responses::ResponseCreateParams::StreamOptions?, temperature: Float?, - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::ResponseCreateParams::Text, tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, tools: ::Array[OpenAI::Models::Responses::tool], top_logprobs: Integer?, @@ -83,11 +83,11 @@ module OpenAI attr_accessor temperature: Float? - attr_reader text: OpenAI::Responses::ResponseTextConfig? + attr_reader text: OpenAI::Responses::ResponseCreateParams::Text? def text=: ( - OpenAI::Responses::ResponseTextConfig - ) -> OpenAI::Responses::ResponseTextConfig + OpenAI::Responses::ResponseCreateParams::Text + ) -> OpenAI::Responses::ResponseCreateParams::Text attr_reader tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice? @@ -130,7 +130,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Responses::ResponseCreateParams::StreamOptions?, ?temperature: Float?, - ?text: OpenAI::Responses::ResponseTextConfig, + ?text: OpenAI::Responses::ResponseCreateParams::Text, ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_logprobs: Integer?, @@ -159,7 +159,7 @@ module OpenAI store: bool?, stream_options: OpenAI::Responses::ResponseCreateParams::StreamOptions?, temperature: Float?, - text: OpenAI::Responses::ResponseTextConfig, + text: OpenAI::Responses::ResponseCreateParams::Text, tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, tools: ::Array[OpenAI::Models::Responses::tool], top_logprobs: Integer?, @@ -203,6 +203,44 @@ module OpenAI def to_hash: -> { include_obfuscation: bool } end + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config, + verbosity: OpenAI::Models::Responses::ResponseCreateParams::Text::verbosity? + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + attr_accessor verbosity: OpenAI::Models::Responses::ResponseCreateParams::Text::verbosity? + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config, + ?verbosity: OpenAI::Models::Responses::ResponseCreateParams::Text::verbosity? + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config, + verbosity: OpenAI::Models::Responses::ResponseCreateParams::Text::verbosity? + } + + type verbosity = :low | :medium | :high + + module Verbosity + extend OpenAI::Internal::Type::Enum + + LOW: :low + MEDIUM: :medium + HIGH: :high + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseCreateParams::Text::verbosity] + end + end + type tool_choice = OpenAI::Models::Responses::tool_choice_options | OpenAI::Responses::ToolChoiceAllowed diff --git a/sig/openai/models/upload_create_params.rbs b/sig/openai/models/upload_create_params.rbs index 85f45a52..f9f767fb 100644 --- a/sig/openai/models/upload_create_params.rbs +++ b/sig/openai/models/upload_create_params.rbs @@ -5,7 +5,8 @@ module OpenAI bytes: Integer, filename: String, mime_type: String, - purpose: OpenAI::Models::file_purpose + purpose: OpenAI::Models::file_purpose, + expires_after: OpenAI::UploadCreateParams::ExpiresAfter } & OpenAI::Internal::Type::request_parameters @@ -21,11 +22,18 @@ module OpenAI attr_accessor purpose: OpenAI::Models::file_purpose + attr_reader expires_after: OpenAI::UploadCreateParams::ExpiresAfter? + + def expires_after=: ( + OpenAI::UploadCreateParams::ExpiresAfter + ) -> OpenAI::UploadCreateParams::ExpiresAfter + def initialize: ( bytes: Integer, filename: String, mime_type: String, purpose: OpenAI::Models::file_purpose, + ?expires_after: OpenAI::UploadCreateParams::ExpiresAfter, ?request_options: OpenAI::request_opts ) -> void @@ -34,8 +42,21 @@ module OpenAI filename: String, mime_type: String, purpose: OpenAI::Models::file_purpose, + expires_after: OpenAI::UploadCreateParams::ExpiresAfter, request_options: OpenAI::RequestOptions } + + type expires_after = { anchor: :created_at, seconds: Integer } + + class ExpiresAfter < OpenAI::Internal::Type::BaseModel + attr_accessor anchor: :created_at + + attr_accessor seconds: Integer + + def initialize: (seconds: Integer, ?anchor: :created_at) -> void + + def to_hash: -> { anchor: :created_at, seconds: Integer } + end end end end diff --git a/sig/openai/resources/batches.rbs b/sig/openai/resources/batches.rbs index b5382fa1..ca6f761c 100644 --- a/sig/openai/resources/batches.rbs +++ b/sig/openai/resources/batches.rbs @@ -6,6 +6,7 @@ module OpenAI endpoint: OpenAI::Models::BatchCreateParams::endpoint, input_file_id: String, ?metadata: OpenAI::Models::metadata?, + ?output_expires_after: OpenAI::BatchCreateParams::OutputExpiresAfter, ?request_options: OpenAI::request_opts ) -> OpenAI::Batch diff --git a/sig/openai/resources/chat/completions.rbs b/sig/openai/resources/chat/completions.rbs index a4237ff1..0634d0eb 100644 --- a/sig/openai/resources/chat/completions.rbs +++ b/sig/openai/resources/chat/completions.rbs @@ -31,6 +31,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Chat::ChatCompletionStreamOptions?, ?temperature: Float?, + ?text: OpenAI::Chat::CompletionCreateParams::Text, ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, ?tools: ::Array[OpenAI::Models::Chat::chat_completion_tool], ?top_logprobs: Integer?, @@ -68,6 +69,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Chat::ChatCompletionStreamOptions?, ?temperature: Float?, + ?text: OpenAI::Chat::CompletionCreateParams::Text, ?tool_choice: OpenAI::Models::Chat::chat_completion_tool_choice_option, ?tools: ::Array[OpenAI::Models::Chat::chat_completion_tool], ?top_logprobs: Integer?, diff --git a/sig/openai/resources/files.rbs b/sig/openai/resources/files.rbs index 49435b99..759285d0 100644 --- a/sig/openai/resources/files.rbs +++ b/sig/openai/resources/files.rbs @@ -4,6 +4,7 @@ module OpenAI def create: ( file: OpenAI::Internal::file_input, purpose: OpenAI::Models::file_purpose, + ?expires_after: OpenAI::FileCreateParams::ExpiresAfter, ?request_options: OpenAI::request_opts ) -> OpenAI::FileObject diff --git a/sig/openai/resources/responses.rbs b/sig/openai/resources/responses.rbs index 502b7174..235cf7b8 100644 --- a/sig/openai/resources/responses.rbs +++ b/sig/openai/resources/responses.rbs @@ -22,7 +22,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Responses::ResponseCreateParams::StreamOptions?, ?temperature: Float?, - ?text: OpenAI::Responses::ResponseTextConfig, + ?text: OpenAI::Responses::ResponseCreateParams::Text, ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_logprobs: Integer?, @@ -51,7 +51,7 @@ module OpenAI ?store: bool?, ?stream_options: OpenAI::Responses::ResponseCreateParams::StreamOptions?, ?temperature: Float?, - ?text: OpenAI::Responses::ResponseTextConfig, + ?text: OpenAI::Responses::ResponseCreateParams::Text, ?tool_choice: OpenAI::Models::Responses::ResponseCreateParams::tool_choice, ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_logprobs: Integer?, diff --git a/sig/openai/resources/uploads.rbs b/sig/openai/resources/uploads.rbs index 50996546..28663206 100644 --- a/sig/openai/resources/uploads.rbs +++ b/sig/openai/resources/uploads.rbs @@ -8,6 +8,7 @@ module OpenAI filename: String, mime_type: String, purpose: OpenAI::Models::file_purpose, + ?expires_after: OpenAI::UploadCreateParams::ExpiresAfter, ?request_options: OpenAI::request_opts ) -> OpenAI::Upload diff --git a/test/openai/resources/responses_test.rb b/test/openai/resources/responses_test.rb index 28d1d7e4..cf4ce20f 100644 --- a/test/openai/resources/responses_test.rb +++ b/test/openai/resources/responses_test.rb @@ -36,7 +36,7 @@ def test_create safety_identifier: String | nil, service_tier: OpenAI::Responses::Response::ServiceTier | nil, status: OpenAI::Responses::ResponseStatus | nil, - text: OpenAI::Responses::ResponseTextConfig | nil, + text: OpenAI::Responses::Response::Text | nil, top_logprobs: Integer | nil, truncation: OpenAI::Responses::Response::Truncation | nil, usage: OpenAI::Responses::ResponseUsage | nil, @@ -78,7 +78,7 @@ def test_retrieve safety_identifier: String | nil, service_tier: OpenAI::Responses::Response::ServiceTier | nil, status: OpenAI::Responses::ResponseStatus | nil, - text: OpenAI::Responses::ResponseTextConfig | nil, + text: OpenAI::Responses::Response::Text | nil, top_logprobs: Integer | nil, truncation: OpenAI::Responses::Response::Truncation | nil, usage: OpenAI::Responses::ResponseUsage | nil, @@ -128,7 +128,7 @@ def test_cancel safety_identifier: String | nil, service_tier: OpenAI::Responses::Response::ServiceTier | nil, status: OpenAI::Responses::ResponseStatus | nil, - text: OpenAI::Responses::ResponseTextConfig | nil, + text: OpenAI::Responses::Response::Text | nil, top_logprobs: Integer | nil, truncation: OpenAI::Responses::Response::Truncation | nil, usage: OpenAI::Responses::ResponseUsage | nil, From ba41a6898ff43f44cd9752a63b11f880c48f59ea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:12:36 +0000 Subject: [PATCH 5/5] release: 0.18.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 22 ++++++++++++++++++++++ Gemfile.lock | 2 +- README.md | 2 +- lib/openai/version.rb | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 463488b6..4ad3fef3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.17.1" + ".": "0.18.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a1823fa6..f32d4899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## 0.18.0 (2025-08-15) + +Full Changelog: [v0.17.1...v0.18.0](https://github.com/openai/openai-ruby/compare/v0.17.1...v0.18.0) + +### ⚠ BREAKING CHANGES + +* structured output desc should go on array items not array itself ([#799](https://github.com/openai/openai-ruby/issues/799)) + +### Features + +* **api:** add new text parameters, expiration options ([f318432](https://github.com/openai/openai-ruby/commit/f318432b19800ab42d5b0c5f179f0cdd02dbf596)) + + +### Bug Fixes + +* structured output desc should go on array items not array itself ([#799](https://github.com/openai/openai-ruby/issues/799)) ([ff507d0](https://github.com/openai/openai-ruby/commit/ff507d095ff703ba3b44ab82b06eb4314688d4eb)) + + +### Chores + +* **internal:** update test skipping reason ([c815703](https://github.com/openai/openai-ruby/commit/c815703062ce79d2cb14f252ee5d23cf4ebf15ca)) + ## 0.17.1 (2025-08-09) Full Changelog: [v0.17.0...v0.17.1](https://github.com/openai/openai-ruby/compare/v0.17.0...v0.17.1) diff --git a/Gemfile.lock b/Gemfile.lock index cbdbfc91..2a86b134 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - openai (0.17.1) + openai (0.18.0) connection_pool GEM diff --git a/README.md b/README.md index bac257a3..631e0c9c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "openai", "~> 0.17.1" +gem "openai", "~> 0.18.0" ``` diff --git a/lib/openai/version.rb b/lib/openai/version.rb index 32d93453..a326627c 100644 --- a/lib/openai/version.rb +++ b/lib/openai/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module OpenAI - VERSION = "0.17.1" + VERSION = "0.18.0" end