> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini 4 Hydrogen

> Use Gemini 4 Hydrogen for text reasoning, multimodal understanding, structured output, function calling, and grounded tool workflows.

Gemini 4 Hydrogen is Google's fast, efficient model for everyday coding, multimodal knowledge work, and agentic workflows. It is designed for rapid execution on its own or as an execution model alongside frontier models. Use the stable model ID `gemini-4-hydrogen` with `POST /v1beta/models/gemini-4-hydrogen:generateContent`.

## Model specifications

| Property | Value |
| - | - |
| Model ID | `gemini-4-hydrogen` |
| Release stage | Generally available |
| Input | Text, image, video, audio, and PDF |
| Output | Text |
| Unified input and output context | 1,048,576 tokens |
| Foreground output limit | 65,536 tokens |
| Long decode output limit | Up to 1,048,576 tokens minus input tokens |
| Thinking levels | `low`, `medium`, `high`, `xhigh` |
| Default thinking level | `high` |

## Key capabilities

* **Long-context reasoning** — Share up to 1,048,576 input, thinking, and output tokens in one context window.
* **Multimodal understanding** — Analyze text, images, video, audio, and PDF documents; the model returns text.
* **Agentic workflows** — Use function calling, code execution, Google Search, Google Maps, URL context, and Computer Use (Preview).
* **Structured output** — Constrain responses with `responseMimeType` and `responseSchema`.
* **Long decode** — The native endpoint can return a `continuationToken` when a foreground segment reaches its output limit. Use the token with a continuation-capable client when you need a response beyond 65,536 output tokens; the unified request budget remains 1,048,576 tokens minus input tokens.

## Choose a workflow

> [tab] Text and thinking
>
> Send text in `contents[].parts[].text`. Use `generationConfig.thinkingConfig.thinkingLevel` to trade latency for reasoning depth. Valid values are `low`, `medium`, `high`, and `xhigh`; the default is `high`.
>
> | Level | Recommended use |
> | - | - |
> | `low` | Latency-sensitive chat, drafting, and quick analysis |
> | `medium` | Balanced coding and agent workflows |
> | `high` | Difficult reasoning and multi-step tool orchestration; this is the default |
> | `xhigh` | The deepest reasoning for the hardest tasks |
>
> The final conversation turn must be a non-empty `user` turn. Do not prefill a response by ending the request with a `model` turn.

> [tab] Multimodal understanding
>
> Combine text with images, audio, video, or PDF documents in the same `contents` request.
>
> * Use `inlineData` with `mimeType` and Base64-encoded `data` for inline media.
> * Use `fileData` with `mimeType` and `fileUri` for an accessible media or document URI.
> * Keep each media item inside the `parts` array for the turn that refers to it.
> * The model returns text; it does not generate image, audio, or video output.
>
> Base64 encoding increases request size. Prefer `fileData` for large assets or files reused across requests.

> [tab] Structured output
>
> Set `generationConfig.responseMimeType` to `application/json` and supply `generationConfig.responseSchema` to constrain the output.
>
> Use a focused schema with explicit `required` fields. The returned JSON is contained in a text part, so parse `candidates[].content.parts[].text` after checking `finishReason`.

> [tab] Function calling
>
> Add functions under `tools[].functionDeclarations`. Control selection with `toolConfig.functionCallingConfig`.
>
> Supported modes are `AUTO`, `ANY`, `NONE`, and `VALIDATED`. Use `allowedFunctionNames` to restrict the callable subset.
>
> Preserve every `thoughtSignature` returned by the model when replaying conversation history. A `functionResponse` must include the function `name`; return the model-provided call `id` and your structured `response` when available.

> [tab] Built-in tools
>
> Gemini 4 Hydrogen can use the following built-in tools on the current endpoint:
>
> | Tool field | Purpose |
> | - | - |
> | `googleSearch` | Ground answers with current web results |
> | `googleMaps` | Ground location answers with Google Maps data |
> | `urlContext` | Read and analyze supplied web pages |
> | `codeExecution` | Run model-generated code and return its result |
> | `computerUse` | Propose browser actions; this capability is in Preview |
>
> Read the returned `groundingMetadata`, `executableCode`, `codeExecutionResult`, or tool-call parts instead of assuming every response contains only text.

## Request examples

> [tab] Text and thinking
>
> ```bash cURL theme={null}
> curl "https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Review this retry design, identify race conditions, and propose a safe implementation plan."}]
>     }],
>     "generationConfig": {
>       "thinkingConfig": {"thinkingLevel": "high"},
>       "maxOutputTokens": 2048
>     }
>   }'
> ```

> [tab] Multimodal understanding
>
> ```bash cURL theme={null}
> curl "https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [{
>       "role": "user",
>       "parts": [
>         {"text": "Summarize the architecture and identify the likely bottleneck."},
>         {
>           "fileData": {
>             "mimeType": "image/png",
>             "fileUri": "https://example.com/architecture.png"
>           }
>         }
>       ]
>     }]
>   }'
> ```

> [tab] Structured output
>
> ```bash cURL theme={null}
> curl "https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Extract the service name, severity, and recommended action from this incident: demo-api is timing out and requires immediate rollback."}]
>     }],
>     "generationConfig": {
>       "responseMimeType": "application/json",
>       "responseSchema": {
>         "type": "object",
>         "properties": {
>           "service": {"type": "string"},
>           "severity": {"type": "string"},
>           "action": {"type": "string"}
>         },
>         "required": ["service", "severity", "action"]
>       }
>     }
>   }'
> ```

> [tab] Function calling
>
> ```bash cURL theme={null}
> curl "https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Check the deployment status for demo-api."}]
>     }],
>     "tools": [{
>       "functionDeclarations": [{
>         "name": "get_deployment_status",
>         "description": "Return the current deployment status for a service.",
>         "parameters": {
>           "type": "object",
>           "properties": {"service": {"type": "string"}},
>           "required": ["service"]
>         }
>       }]
>     }],
>     "toolConfig": {
>       "functionCallingConfig": {
>         "mode": "ANY",
>         "allowedFunctionNames": ["get_deployment_status"]
>       }
>     }
>   }'
> ```

> [tab] Built-in tools
>
> ```bash cURL theme={null}
> curl "https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Find the latest stable Gemini API model and cite the source."}]
>     }],
>     "tools": [{"googleSearch": {}}]
>   }'
> ```

## Generation controls

| Parameter | Type | Description |
| - | - | - |
| `thinkingConfig.thinkingLevel` | string | `low`, `medium`, `high`, or `xhigh`; defaults to `high` |
| `maxOutputTokens` | integer | Maximum generated tokens for a foreground request, up to 65,536 per segment; longer decodes may return a `continuationToken` |
| `responseMimeType` | string | `text/plain`, `application/json`, or `text/x.enum` |
| `responseSchema` | object | Schema used to constrain structured output |
| `stopSequences` | string\[] | Up to five sequences that stop generation |

## Conversation and response handling

* Use `user` and `model` roles for conversation history.
* Preserve complete model turns and every `thoughtSignature` in multi-step function workflows.
* Check `candidates[].finishReason` before consuming the output.
* Read token counts from `usageMetadata`, including `thoughtsTokenCount` for reasoning usage. Responses can also include `createTime`, `promptTokensDetails`, `candidatesTokensDetails`, and `continuationToken`.
* Search and Maps responses can include `groundingMetadata` with queries, sources, and supporting segments.
* Code execution can return `executableCode` and `codeExecutionResult` parts.

> [!WARNING]
>
> Do not send `temperature`, `topP`, `topK`, or `candidateCount`. Google documents these sampling controls as ignored for Gemini 4 Hydrogen. Explicit context caching is also unsupported; implicit caching may apply automatically.

> [card] [API Reference](https://docs.anyfast.ai/api-reference/model-api/google/gemini-4-hydrogen.md)
>
> View request fields, capability examples, and response schemas for Gemini 4 Hydrogen.

## Official references

* [Gemini 4 Hydrogen model page](https://aistudio.google.com/docs/models/gemini-4-hydrogen)
* [What's new in Gemini 4 Hydrogen](https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-gemini-4-Hydrogen/)
* [Generate content API](https://ai.google.dev/api/generate-content)
* [Gemini function calling](https://ai.google.dev/gemini-api/docs/generate-content/function-calling)
* [Gemini thinking](https://ai.google.dev/gemini-api/docs/thinking)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.