Skip to content

toGeminiContents

function toGeminiContents(messages): object;

Defined in: core/src/providers/gemini.ts:223

Our messages → Gemini contents.

Three shape differences the rest of the adapter must not have to know about: system text is lifted out and merged into ONE instruction (Gemini takes a single one, not a role in the turn list); assistant turns are role model and carry tool calls as functionCall parts with the thought signature beside them; tool results are role user with a functionResponse part naming the FUNCTION, since Gemini pairs a result to its call by name.

A run of results is ONE user turn: Gemini answers a model turn’s parallel calls with every response together, and spread over several turns it 400s that the response count does not match the call count. The responses go first, in call order, and the run’s images follow them all, the way the OpenAI dialect places them.

Parameter Type
messages readonly ChatMessage[]

object

contents: GeminiContent[];
optional system?: string;