Class: PromptBuilder::Serializers::ChatCompletion::Request

Inherits:
Base
  • Object
show all
Defined in:
lib/prompt_builder/serializers/chat_completion/request.rb

Overview

Request serializer for the OpenAI Chat Completions API format.

Unsupported Open Responses features

These session fields are not supported and are silently omitted from the serialized output:

  • background — Chat Completions has no background/async mode
  • include — response-field inclusion is an Open Responses-only concept
  • max_tool_calls — per-request tool-call caps are not supported
  • truncation — server-side context truncation is not supported

Partially supported session fields (unsupported keys are omitted):

  • text — only format (mapped to response_format) and verbosity (mapped to top-level verbosity) are supported
  • reasoning — only the effort key is mapped to reasoning_effort
  • stream_options — only include_usage and include_obfuscation are supported, and only when stream is set (otherwise it is omitted)

Input content restrictions:

  • InputVideo content is not supported in any message (omitted)
  • Reasoning items are not supported (skipped)
  • RefusalContent is dropped silently (a parsed Chat Completions refusal can stay in session history without breaking subsequent request_payload calls)
  • InputImage content is only supported in user messages (assistant/developer/system images are omitted)
  • InputImage with file_id in extra is not supported (the image_file content type is Assistants API only); a +file_id+-only image is omitted
  • InputFile is mapped to a file content block (Files API id via extra, base64 file_data, or both with filename); a +file_url+-only InputFile is omitted because Chat Completions has no remote-URL form for files
  • Only text content is supported in tool (+FunctionCallOutput+) results; other content is omitted
  • OutputText.annotations are dropped silently on request serialization so a parsed response with citations can sit in session history without breaking subsequent request_payload calls

Features in Chat Completions not available through Open Responses

The following Chat Completions parameters cannot be set through the Open Responses canonical format:

  • seed — for reproducible outputs
  • logit_bias — per-token probability adjustments
  • n — requesting multiple response candidates
  • stop — custom stop sequences
  • prediction — speculative decoding hints
  • Audio input and audio output (model-dependent)
  • web_search_options — built-in web search tool
  • modalities — output modality selection (text/audio)
  • tool_choice allowed_tools shape and custom (non-function) tool types

Constant Summary collapse

SUPPORTED_MESSAGE_ROLES =
%w[assistant developer system user].freeze
SUPPORTED_STREAM_OPTION_KEYS =
%w[include_obfuscation include_usage].freeze
SUPPORTED_TOOL_CHOICE_VALUES =
%w[auto none required].freeze

Method Summary

Methods inherited from Base

parse_response, request_payload