Class: OmniAI::OpenAI::Chat

Inherits:
Chat
  • Object
show all
Defined in:
lib/omniai/openai/chat.rb,
lib/omniai/openai/chat/stream.rb,
lib/omniai/openai/chat/url_serializer.rb,
lib/omniai/openai/chat/file_serializer.rb,
lib/omniai/openai/chat/text_serializer.rb,
lib/omniai/openai/chat/tool_serializer.rb,
lib/omniai/openai/chat/usage_serializer.rb,
lib/omniai/openai/chat/choice_serializer.rb,
lib/omniai/openai/chat/content_serializer.rb,
lib/omniai/openai/chat/message_serializer.rb,
lib/omniai/openai/chat/response_serializer.rb,
lib/omniai/openai/chat/thinking_serializer.rb,
lib/omniai/openai/chat/tool_call_serializer.rb,
lib/omniai/openai/chat/tool_call_result_serializer.rb,
lib/omniai/openai/chat/tool_call_message_serializer.rb

Overview

An OpenAI chat implementation.

Usage:

completion = OmniAI::OpenAI::Chat.process!(client: client) do |prompt|
prompt.system('You are an expert in the field of AI.')
prompt.user('What are the biggest risks of AI?')
end
completion.choice.message.content # '...'

Defined Under Namespace

Modules: ChoiceSerializer, ContentSerializer, FileSerializer, MessageSerializer, Model, ReasoningEffort, ResponseFormat, ResponseSerializer, TextSerializer, ThinkingSerializer, ToolCallMessageSerializer, ToolCallResultSerializer, ToolCallSerializer, ToolSerializer, URLSerializer, UsageSerializer, VerbosityText Classes: Stream

Constant Summary collapse

DEFAULT_MODEL =
Model::GPT_5_2
TEMPERATURE_UNSUPPORTED_MODELS =

Models that reject temperature on the Responses API.

OpenAI's support here is not patterned by version, so this cannot be a prefix rule: gpt-5 and its mini/nano/pro variants reject temperature, gpt-5.1 through gpt-5.4 accept it, and gpt-5.5 onwards rejects it again. Every entry below was verified live against the API on 2026-08-16 by issuing a request with temperature and checking for Unsupported parameter.

Models absent from this list pass temperature through unchanged. That is deliberate: an unlisted model that rejects it surfaces a loud API error the caller can act on, whereas over-applying the guard would silently discard a caller's temperature.

[
  Model::GPT_5_6_LUNA,
  Model::GPT_5_6_SOL,
  Model::GPT_5_6_TERRA,
  Model::GPT_5_5,
  Model::GPT_5_5_PRO,
  Model::GPT_5_4_PRO,
  Model::GPT_5_2_PRO,
  Model::GPT_5,
  Model::GPT_5_MINI,
  Model::GPT_5_NANO,
  Model::GPT_5_PRO,
  Model::O1_MINI,
  Model::O1,
  Model::O3,
  Model::O3_MINI,
  Model::O4_MINI,
].freeze
RESERVED_OPTIONS =

Keys in @options consumed by dedicated builders below rather than sent verbatim.

%i[text reasoning thinking].freeze
CONTEXT =

Returns:

  • (Context)
Context.build do |context|
  context.serializers[:choice] = ChoiceSerializer.method(:serialize)
  context.deserializers[:choice] = ChoiceSerializer.method(:deserialize)
  context.serializers[:message] = MessageSerializer.method(:serialize)
  context.deserializers[:message] = MessageSerializer.method(:deserialize)
  context.serializers[:text] = TextSerializer.method(:serialize)
  context.deserializers[:text] = TextSerializer.method(:deserialize)
  context.serializers[:response] = ResponseSerializer.method(:serialize)
  context.deserializers[:response] = ResponseSerializer.method(:deserialize)
  context.deserializers[:content] = ContentSerializer.method(:deserialize)
  context.deserializers[:usage] = UsageSerializer.method(:deserialize)
  context.serializers[:file] = FileSerializer.method(:serialize)
  context.serializers[:url] = URLSerializer.method(:serialize)
  context.serializers[:tool] = ToolSerializer.method(:serialize)
  context.serializers[:tool_call] = ToolCallSerializer.method(:serialize)
  context.deserializers[:tool_call] = ToolCallSerializer.method(:deserialize)
  context.serializers[:tool_call_result] = ToolCallResultSerializer.method(:serialize)
  context.deserializers[:tool_call_result] = ToolCallResultSerializer.method(:deserialize)
  context.serializers[:tool_call_message] = ToolCallMessageSerializer.method(:serialize)
  context.deserializers[:tool_call_message] = ToolCallMessageSerializer.method(:deserialize)
  context.serializers[:thinking] = ThinkingSerializer.method(:serialize)
  context.deserializers[:thinking] = ThinkingSerializer.method(:deserialize)
end