Class: PromptBuilder::Serializers::Gemini::Request
- Defined in:
- lib/prompt_builder/serializers/gemini/request.rb
Overview
Request serializer for the Google Gemini API format.
Unsupported Open Responses features
These session fields are not supported and are silently omitted from the serialized output:
background— Gemini has no background/async mode on the generate endpointinclude— response-field inclusion is an Open Responses-only conceptmax_tool_calls— per-request tool-call caps are not supportedmetadata— arbitrary metadata is not supportedparallel_tool_calls— parallel tool call control is not supportedprompt_cache_key/prompt_cache_retention— explicit prompt cache keys are not supportedsafety_identifier— no equivalent user-safety field on the generate endpointstream_options— stream event options are not supportedtruncation— server-side context truncation is not supported
Input content restrictions:
InputImagecontent is only supported in user messages (assistant images are omitted)InputImagewithimage_urlrequires either base64dataor a URL; content withoutimage_urlorfile_idraisesInputFilecontent is only supported in user messages (assistant files are omitted)InputFilerequiresmedia_typewhenfile_datais provided, or a recognized extension onfilename/file_urlInputVideorequiresvideo_urlRefusalContentis dropped silently (a parsed Chat Completions refusal can stay in session history without breaking subsequent request_payload calls)redacted_thinkingand unknown reasoning blocks are silently skippedReasoningitems withsummaryblocks have the summary skippedFunctionCallOutputarray contents must be text-only; other content is omittedCompactionandItemReferenceitems are silently skipped
Features in Gemini not available through Open Responses
The following Gemini parameters cannot be set through the Open Responses canonical format:
thinkingConfig.thinkingBudget— usereasoning.budget_tokensinsteadthinkingConfig.thinkingLevel— usereasoning.effortinsteadthinkingConfig.includeThoughts— usereasoning.summary = "auto"insteadtopK— top-K sampling parameterseed— for reproducible outputs (model-dependent)stopSequences— custom stop sequencescandidateCount— requesting multiple response candidatesresponseModalities— selecting TEXT/IMAGE/AUDIO output channelsresponseJsonSchema— newer JSON Schema variant ofresponseSchemasafetySettings— configurable harm-category safety thresholdsmediaResolution— controls token cost of image/video inputsaudioTimestamp,speechConfig— audio output configurationenableEnhancedCivicAnswersroutingConfig,modelSelectionConfig- Video metadata controls (+videoMetadata+ offset, FPS) on +Part+s
- Audio input model capability controls (audio can be sent as
InputFilewith an audio MIME type) - Built-in Gemini tools:
googleSearch/googleSearchRetrieval,codeExecution,urlContext,computerUse,fileSearch,googleMaps,mcpServers functionCallingConfig.mode = VALIDATEDtoolConfig.retrievalConfig,includeServerSideToolInvocationscachedContent— referencing a CachedContent resource by name- Top-level
labels(Vertex flavor only)
Constant Summary collapse
- SUPPORTED_REASONING_EFFORTS =
%w[minimal low medium high].freeze
- SUPPORTED_REASONING_SUMMARIES =
%w[auto].freeze
- SUPPORTED_SERVICE_TIERS =
%w[unspecified standard flex priority].freeze