Skip to content
3 min read · 529 words

@nhtio/adk/batteries/llm/gemini_generate_content/types ​

Wire shapes, helper contracts, and option types for the native Gemini generateContent battery.

Remarks ​

Gemini's native surface differs from OpenAI Chat Completions in every structural respect, which is why pointing the openai_chat_completions battery at a Gemini-compatible gateway is not equivalent to speaking generateContent:

  • Turns are contents[], not messages[], and the assistant role is model, not assistant. There is no system role: system text goes in a separate top-level systemInstruction.
  • A turn's payload is parts[] — a heterogeneous array. A tool call is a functionCall part on a model turn; its result is a functionResponse part on a user turn. So the OpenAI-shaped "assistant with tool_calls, then a tool-role message" becomes "model turn with a functionCall part, then a user turn with a functionResponse part".
  • functionResponse.name must match the DECLARED tool name, not a call id. Gemini has no tool_call_id concept, so correlation is positional/by-name.
  • Gemini 3+ rejects a historical functionCall part that carries no thoughtSignature. Google documents two portable sentinels for replaying traces that did not originate from Gemini; see GeminiGenerateContentAdapterOptions.thoughtSignatureSentinel.
  • Generation settings live under generationConfig (maxOutputTokens, temperature, topP, topK, stopSequences, thinkingConfig), and tools under tools[].functionDeclarations[].

Wire-shape-agnostic types (JsonSchema, the attribute envelopes, UnsupportedMediaPolicy, the bucket order, the retry config, the observability taps) come from the shared internal ../chat_common/types submodule and are re-exported so consumers of this battery get a self-contained type surface.

Interfaces ​

InterfaceDescription
GeminiCandidateOne generation candidate.
GeminiContentOne conversation turn.
GeminiFunctionCallA model-emitted request to invoke a declared function.
GeminiFunctionDeclarationA tool Gemini may call, in its native declaration shape.
GeminiFunctionResponseThe result of a function invocation, sent back on a user turn.
GeminiGenerateContentAdapterOptionsConstructor and per-dispatch options.
GeminiGenerateContentHelpersThe injectable translation seam.
GeminiGenerateContentRequestThe complete :generateContent request body.
GeminiGenerateContentResponseThe :generateContent response body (also each SSE frame of :streamGenerateContent).
GeminiGenerationConfigSampling and output controls.
GeminiInlineDataInline binary data (image/audio/etc.) as Gemini carries it.
GeminiPartOne element of a turn's parts[].
GeminiRequestBuildInputEverything buildGeminiRequest needs to assemble a request.
GeminiSafetySettingOne safety-filter setting.
GeminiThinkingConfigReasoning-budget controls.
GeminiToolThe tools[] entry wrapping function declarations.
GeminiToolConfigForces, permits, or forbids function calling.
GeminiUsageMetadataPer-candidate token accounting.

Type Aliases ​

Type AliasDescription
GeminiRoleA conversation role on the generateContent wire.

References ​

ChatCompletionsBucketLabel ​

Re-exports ChatCompletionsBucketLabel


ChatCompletionsBucketOrder ​

Re-exports ChatCompletionsBucketOrder


ChatCompletionsRetryConfig ​

Re-exports ChatCompletionsRetryConfig


ChatHelpersCommon ​

Re-exports ChatHelpersCommon


DescriptionLike ​

Re-exports DescriptionLike


JsonSchema ​

Re-exports JsonSchema


MemoryAttrs ​

Re-exports MemoryAttrs


PromptAssembledObserverFn ​

Re-exports PromptAssembledObserverFn


RawGenerationObserverFn ​

Re-exports RawGenerationObserverFn


RetrievableAttrs ​

Re-exports RetrievableAttrs


StandingInstructionAttrs ​

Re-exports StandingInstructionAttrs


ThoughtAttrs ​

Re-exports ThoughtAttrs


ToolCallParserFn ​

Re-exports ToolCallParserFn


ToolCallParserName ​

Re-exports ToolCallParserName


TrustedContentAttrs ​

Re-exports TrustedContentAttrs


UnsupportedMediaPolicy ​

Re-exports UnsupportedMediaPolicy


UntrustedContentAttrs ​

Re-exports UntrustedContentAttrs