google.internal.gemini_build_body

ai.ModelTurnInput -> the serialized generateContent body.

Reference version

Signature

function google.internal.gemini_build_body(
input: ai.ModelTurnInput,
client_id: string,
generation_config: google.internal.GmGenerationConfig | null,
safety_settings: google.SafetySetting[] | null,
request_body: baml.json.json | null,
fetch_url: bool = …,
preview: bool = …
) -> string throws baml.errors.InvalidArgument | baml.errors.Io | baml.errors.Timeout | baml.json.SerializationError | ai.errors.InvalidRequest | ai.errors.NetworkFailure | ai.errors.PreviewUnsupported | ai.errors.PromptRenderError

ai.ModelTurnInput -> the serialized generateContent body.

The last step is always ai.wire.merge_request_body, so request_body overrides everything the typed request built (and a null value in it DELETES the key the client injected).

fetch_url is the backend's media strategy (see _gm_media_part): the Developer API inlines http(s) media, Vertex passes the URL through.

Source:<builtin>/google/ns_internal/gemini.bamlbytes 2533728277