Class: PromptBuilder::Serializers::ChatCompletion::Request
- Defined in:
- lib/prompt_builder/serializers/chat_completion/request.rb
Overview
Request serializer for the OpenAI Chat Completions API format.
Required session fields (an UnsupportedFormatError is raised when missing):
model- at least one message (+instructions+ or a conversation item that serializes to a message)
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 modeinclude— response-field inclusion is an Open Responses-only conceptmax_tool_calls— per-request tool-call caps are not supportedtruncation— server-side context truncation is not supported
Partially supported session fields (unsupported keys are omitted):
text— onlyformat(mapped toresponse_format) andverbosity(mapped to top-levelverbosity) are supportedreasoning— only theeffortkey is mapped toreasoning_effortstream_options— onlyinclude_usageandinclude_obfuscationare supported, and only whenstreamis set (otherwise it is omitted)
Input content restrictions:
instructionsis serialized as a system message inserted after the last system/developer message, or first when there are none (instructions apply to the current request, matching Open Responses semantics)InputVideocontent is not supported in any message (omitted)Reasoningitems are not supported (skipped)RefusalContentis dropped silently (a parsed Chat Completions refusal can stay in session history without breaking subsequent request_payload calls)InputImagecontent is only supported in user messages (assistant/developer/system images are omitted)InputImagewithfile_idinextrais not supported (theimage_filecontent type is Assistants API only); a +file_id+-only image is omittedInputFileis mapped to afilecontent block (Files API id viaextra, base64file_data, or both withfilename); a +file_url+-onlyInputFileis 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.annotationsare dropped silently on request serialization so a parsed response with citations can sit in session history without breaking subsequentrequest_payloadcalls
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 outputslogit_bias— per-token probability adjustmentsn— requesting multiple response candidatesstop— custom stop sequencesprediction— speculative decoding hints- Audio input and audio output (model-dependent)
web_search_options— built-in web search toolmodalities— output modality selection (text/audio)tool_choiceallowed_toolsshape 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