---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/gemini_generate_content/helpers/functions/buildGeminiRequest.md
---

# Function: buildGeminiRequest()

```ts
function buildGeminiRequest(
  input: GeminiRequestBuildInput,
): Promise<GeminiGenerateContentRequest>;
```

Defined in: [src/batteries/llm/gemini\_generate\_content/helpers.ts:257](https://github.com/NHTIO/ADK/blob/master/src/src/batteries/llm/gemini_generate_content/helpers.ts#L257)

Assemble the native request from ADK turn state. THE ordering seam.

## Parameters

| Parameter | Type                                                                           |
| --------- | ------------------------------------------------------------------------------ |
| `input`   | [`GeminiRequestBuildInput`](../../types/interfaces/GeminiRequestBuildInput.md) |

## Returns

`Promise`<[`GeminiGenerateContentRequest`](../../types/interfaces/GeminiGenerateContentRequest.md)>

## Remarks

The translation that makes this battery different from pointing `openai_chat_completions` at a
Gemini gateway:

* System text goes to `systemInstruction`, not a `contents[]` turn.
* `Message.role: 'assistant'` becomes `role: 'model'`.
* A `ToolCall` becomes TWO turns: a `model` turn with a `functionCall` part, then a `user` turn
  with a `functionResponse` part. `functionResponse.name` carries the DECLARED tool name,
  because Gemini has no call-id correlation.
* Timeline order is `createdAt`, matching the ordering guard's own view, so what the guard
  validates is what gets dispatched.
* The thought-signature sentinel is stamped on the FIRST `functionCall` only when no part
  already carries a real signature and the caller has not opted out. Preserving a genuine
  signature matters: it is prefix-bound, and replacing one invalidates it.
