> ## 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

> Generate Gemini 4 Hydrogen responses from text and multimodal input, structured schemas, functions, and built-in tools.

Gemini 4 Hydrogen exposes text reasoning, multimodal understanding, structured output, function calling, and built-in tools through one `generateContent` endpoint. Select a capability to view its request and response shape.

> [tab] Text and thinking
>
> ## Generate content
>
> `POST /v1beta/models/gemini-4-hydrogen:generateContent`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url 'https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [{
>       "role": "user",
>       "parts": [{
>         "text": "Reply with exactly: AnyFast Hydrogen verification passed."
>       }]
>     }],
>     "generationConfig": {
>       "thinkingConfig": {"thinkingLevel": "high"},
>       "maxOutputTokens": 2048
>     }
>   }'
> ```
>
> ## Authentication and headers
>
> **key** `string` *required*
>
> AnyFast API key.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Request media type.
>
> ## Request body
>
> **contents** `object[]` *required*
>
> Conversation history and the current user request. The final item must be a non-empty `user` turn.
>
> **contents\[].role** `string` (default: user)
>
> Conversation role: `user` or `model`. Do not end the request with a `model` turn.
>
> **contents\[].parts** `object[]` *required*
>
> Content parts for the turn.
>
> **contents\[].parts\[].text** `string` *required*
>
> Text prompt or conversation content.
>
> **generationConfig.thinkingConfig.thinkingLevel** `string` (default: high)
>
> Thinking level: `low`, `medium`, `high`, or `xhigh`.
>
> **generationConfig.maxOutputTokens** `integer`
>
> Maximum generated tokens for a synchronous request, from 1 through 65,536 per foreground segment; longer decodes may return a `continuationToken`.
>
> ## Successful response
>
> ```json 200 theme={null}
> {
>   "candidates": [{
>     "content": {
>       "parts": [{"text": "AnyFast Hydrogen verification passed.", "thoughtSignature": "opaque-signature-placeholder"}]
>       "role": "model"
>     },
>     "finishReason": "STOP",
>   }],
>   "usageMetadata": {
>     "promptTokenCount": 41,
>     "candidatesTokenCount": 10,
>     "thoughtsTokenCount": 40,
>     "totalTokenCount": 91,
>     "trafficType": "ON_DEMAND",
>     "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 41}],
>     "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 10}]
>   },
>   "modelVersion": "gemini-4-hydrogen",
>   "createTime": "2026-11-16T02:54:36.249415Z",
>   "responseId": "response-example-001"
> }
> ```
>
> **candidates** `object[]`
>
> Generated candidates.
>
> **candidates\[].content** `object`
>
> Model response turn.
>
> **candidates\[].content.parts\[].text** `string`
>
> Generated text.
>
> **candidates\[].content.parts\[].thoughtSignature** `string`
>
> Opaque signature returned with the model part. Preserve it when replaying the turn.
>
> **candidates\[].finishReason** `string`
>
> Why generation stopped, such as `STOP`, `MAX_TOKENS`, `SAFETY`, or `CONTINUATION`.
>
> **candidates\[].safetyRatings** `object[]`
>
> Safety assessments returned when the candidate is evaluated.
>
> **usageMetadata** `object`
>
> Input, output, reasoning, tool, cache, and total token counts.
>
> **usageMetadata.promptTokensDetails** `object[]`
>
> Input token counts grouped by modality.
>
> **usageMetadata.candidatesTokensDetails** `object[]`
>
> Output token counts grouped by modality.
>
> **modelVersion** `string`
>
> Model version that produced the response.
>
> **createTime** `string`
>
> Response creation timestamp when returned.
>
> **responseId** `string`
>
> Response identifier.
>
> **candidates\[].continuationToken** `string`
>
> Opaque token returned when the foreground segment reaches its output limit and continuation is available.

> [tab] Multimodal understanding
>
> ## Generate content
>
> `POST /v1beta/models/gemini-4-hydrogen:generateContent`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url 'https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [{
>       "role": "user",
>       "parts": [
>         {"text": "Summarize this architecture and identify the likely bottleneck."},
>         {
>           "fileData": {
>             "mimeType": "image/png",
>             "fileUri": "https://example.com/architecture.png"
>           }
>         }
>       ]
>     }]
>   }'
> ```
>
> ## Authentication and headers
>
> **key** `string` *required*
>
> AnyFast API key.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Request media type.
>
> ## Request body
>
> **contents** `object[]` *required*
>
> Conversation turns containing text and media.
>
> **contents\[].role** `string` (default: user)
>
> Conversation role: `user` or `model`.
>
> **contents\[].parts** `object[]` *required*
>
> One or more text or media parts.
>
> **contents\[].parts\[].text** `string`
>
> Instruction or question about the media.
>
> **contents\[].parts\[].inlineData** `object`
>
> Inline image, audio, video, or document data.
>
> **contents\[].parts\[].inlineData.mimeType** `string` *required*
>
> Media MIME type, such as `image/jpeg`, `audio/mpeg`, `video/mp4`, or `application/pdf`.
>
> **contents\[].parts\[].inlineData.data** `string` *required*
>
> Base64-encoded media bytes.
>
> **contents\[].parts\[].fileData** `object`
>
> Media or document supplied by URI.
>
> **contents\[].parts\[].fileData.mimeType** `string` *required*
>
> Media MIME type.
>
> **contents\[].parts\[].fileData.fileUri** `string` *required*
>
> Accessible media or document URI.
>
> ## Successful response
>
> ```json 200 theme={null}
> {
>   "candidates": [{
>     "content": {
>       "parts": [{"text": "The diagram shows a queue-backed worker tier. The database connection pool is the likely bottleneck..."}],
>       "role": "model"
>     },
>     "finishReason": "STOP",
>   }],
>   "usageMetadata": {
>     "promptTokenCount": 846,
>     "candidatesTokenCount": 94,
>     "totalTokenCount": 940,
>     "promptTokensDetails": [
>       {"modality": "TEXT", "tokenCount": 18},
>       {"modality": "IMAGE", "tokenCount": 828}
>     ]
>   },
>   "modelVersion": "gemini-4-hydrogen",
>   "responseId": "response-example-002"
> }
> ```
>
> **candidates\[].content.parts\[].text** `string`
>
> Text analysis of the supplied media.
>
> **candidates\[].finishReason** `string`
>
> Reason generation stopped.
>
> **usageMetadata.promptTokensDetails** `object[]`
>
> Input token counts grouped by modality.
>
> **usageMetadata.candidatesTokensDetails** `object[]`
>
> Output token counts grouped by modality when returned.
>
> **modelVersion** `string`
>
> Model version that produced the response.
>
> **responseId** `string`
>
> Response identifier.

> [tab] Structured output
>
> ## Generate content
>
> `POST /v1beta/models/gemini-4-hydrogen:generateContent`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url 'https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Extract the service, severity, and action: 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"]
>       }
>     }
>   }'
> ```
>
> ## Authentication and headers
>
> **key** `string` *required*
>
> AnyFast API key.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Request media type.
>
> ## Request body
>
> **contents** `object[]` *required*
>
> Conversation turns containing the extraction or generation instruction.
>
> **contents\[].parts\[].text** `string` *required*
>
> Instruction and source text.
>
> **generationConfig.responseMimeType** `string` *required*
>
> Use `application/json` for JSON structured output or `text/x.enum` for a single enum value.
>
> **generationConfig.responseSchema** `object` *required*
>
> Schema that constrains the generated JSON. Define explicit properties and required fields.
>
> ## Successful response
>
> ```json 200 theme={null}
> {
>   "candidates": [{
>     "content": {
>       "parts": [{
>         "text": "{\"service\":\"demo-api\",\"severity\":\"medium\",\"action\":\"retry\"}",
>         "thoughtSignature": "opaque-signature-placeholder"
>       }],
>       "role": "model"
>     },
>     "finishReason": "STOP",
>   }],
>   "usageMetadata": {
>     "promptTokenCount": 238,
>     "candidatesTokenCount": 36,
>     "thoughtsTokenCount": 49,
>     "totalTokenCount": 323,
>     "trafficType": "ON_DEMAND",
>     "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 238}],
>     "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 36}]
>   },
>   "modelVersion": "gemini-4-hydrogen",
>   "responseId": "response-example-003"
> }
> ```
>
> **candidates\[].content.parts\[].text** `string`
>
> JSON serialized as text and conforming to the requested schema.
>
> **candidates\[].content.parts\[].thoughtSignature** `string`
>
> Opaque signature returned with the model part. Preserve it when replaying the turn.
>
> **candidates\[].finishReason** `string`
>
> Reason generation stopped.
>
> **usageMetadata** `object`
>
> Token accounting for the request.
>
> **usageMetadata.promptTokensDetails** `object[]`
>
> Input token counts grouped by modality.
>
> **usageMetadata.candidatesTokensDetails** `object[]`
>
> Output token counts grouped by modality.
>
> **modelVersion** `string`
>
> Model version that produced the response.
>
> **responseId** `string`
>
> Response identifier.

> [tab] Function calling
>
> ## Generate function call
>
> `POST /v1beta/models/gemini-4-hydrogen:generateContent`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url 'https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "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"]
>       }
>     }
>   }'
> ```
>
> ## Authentication and headers
>
> **key** `string` *required*
>
> AnyFast API key.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Request media type.
>
> ## Request body
>
> **contents** `object[]` *required*
>
> Conversation turns containing the user request and, for later steps, previous model calls and function results.
>
> **tools\[].functionDeclarations** `object[]` *required*
>
> Functions available to the model.
>
> **tools\[].functionDeclarations\[].name** `string` *required*
>
> Function name.
>
> **tools\[].functionDeclarations\[].description** `string`
>
> When and how the model should use the function.
>
> **tools\[].functionDeclarations\[].parameters** `object`
>
> JSON Schema for function arguments.
>
> **toolConfig.functionCallingConfig.mode** `string` (default: AUTO)
>
> `AUTO`, `ANY`, `NONE`, or `VALIDATED`.
>
> **toolConfig.functionCallingConfig.allowedFunctionNames** `string[]`
>
> Subset of declared functions the model may call.
>
> **contents\[].parts\[].functionResponse.name** `string` *required*
>
> Function name when returning a tool result.
>
> **contents\[].parts\[].functionResponse.id** `string`
>
> Call ID returned by the model.
>
> **contents\[].parts\[].functionResponse.response** `object`
>
> Structured function result.
>
> **contents\[].parts\[].thoughtSignature** `string`
>
> Opaque signature returned by the model. Preserve it exactly in later requests.
>
> ## Function-call response
>
> ```json 200 theme={null}
> {
>   "candidates": [{
>     "content": {
>       "parts": [{
>         "functionCall": {
>           "name": "lookup_weather",
>           "args": {"city": "Shanghai"},
>           "id": "call-example-001"
>         },
>         "thoughtSignature": "opaque-signature-placeholder"
>       }],
>       "role": "model"
>     },
>     "finishReason": "STOP",
>   }],
>   "usageMetadata": {
>     "promptTokenCount": 93,
>     "candidatesTokenCount": 22,
>     "thoughtsTokenCount": 25,
>     "totalTokenCount": 140,
>     "trafficType": "ON_DEMAND",
>     "promptTokensDetails": [{"modality": "TEXT", "tokenCount": 93}],
>     "candidatesTokensDetails": [{"modality": "TEXT", "tokenCount": 22}]
>   },
>   "modelVersion": "gemini-4-hydrogen",
>   "responseId": "response-example-004"
> }
> ```
>
> **candidates\[].content.parts\[].functionCall** `object`
>
> Function requested by the model.
>
> **candidates\[].content.parts\[].functionCall.id** `string`
>
> Call ID to associate with a returned function result.
>
> **candidates\[].content.parts\[].functionCall.name** `string`
>
> Function name.
>
> **candidates\[].content.parts\[].functionCall.args** `object`
>
> Model-generated function arguments.
>
> **candidates\[].content.parts\[].thoughtSignature** `string`
>
> Opaque signature that must be preserved when the model turn is replayed.
>
> **usageMetadata.toolUsePromptTokenCount** `integer`
>
> Tokens used for tool context when this metric is reported.
>
> **usageMetadata.promptTokensDetails** `object[]`
>
> Input token counts grouped by modality when returned.
>
> **usageMetadata.candidatesTokensDetails** `object[]`
>
> Output token counts grouped by modality when returned.
>
> **responseId** `string`
>
> Response identifier.

> [tab] Built-in tools
>
> ## Generate grounded content
>
> `POST /v1beta/models/gemini-4-hydrogen:generateContent`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url 'https://www.anyfast.ai/v1beta/models/gemini-4-hydrogen:generateContent?key=YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [{
>       "role": "user",
>       "parts": [{"text": "Find the latest stable Gemini API model and cite the source."}]
>     }],
>     "tools": [{"googleSearch": {}}]
>   }'
> ```
>
> ## Authentication and headers
>
> **key** `string` *required*
>
> AnyFast API key.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Request media type.
>
> ## Request body
>
> **contents** `object[]` *required*
>
> Conversation turns containing the tool-assisted request.
>
> **tools\[].googleSearch** `object`
>
> Ground the response with current Google Search results.
>
> **tools\[].googleMaps** `object`
>
> Ground location-related answers with Google Maps data.
>
> **tools\[].urlContext** `object`
>
> Read and analyze URLs supplied in the prompt.
>
> **tools\[].codeExecution** `object`
>
> Allow the model to execute code.
>
> **tools\[].computerUse** `object`
>
> Allow the model to propose computer-use actions. This tool is in Preview.
>
> **tools\[].computerUse.environment** `string`
>
> Computer-use environment, such as `ENVIRONMENT_BROWSER`.
>
> ## Grounded response
>
> ```json 200 theme={null}
> {
>   "candidates": [{
>     "content": {
>       "parts": [{"text": "Gemini 4 Hydrogen is the latest stable Flash model..."}],
>       "role": "model"
>     },
>     "finishReason": "STOP",
>     "groundingMetadata": {
>       "webSearchQueries": ["latest stable Gemini API model"],
>       "searchEntryPoint": {
>         "renderedContent": "<style>...</style><div>...</div>"
>       },
>       "groundingChunks": [{
>         "web": {
>           "uri": "https://ai.google.dev/gemini-api/docs/models",
>           "title": "Gemini models"
>         }
>       }],
>       "groundingSupports": [{
>         "segment": {"startIndex": 0, "endIndex": 56, "text": "Gemini 4 Hydrogen is the latest stable Flash model"},
>         "groundingChunkIndices": [0]
>       }]
>     }
>   }],
>   "usageMetadata": {
>     "promptTokenCount": 15,
>     "candidatesTokenCount": 58,
>     "toolUsePromptTokenCount": 43,
>     "totalTokenCount": 116
>   },
>   "modelVersion": "gemini-4-hydrogen",
>   "responseId": "response-example-005"
> }
> ```
>
> **candidates\[].content.parts** `object[]`
>
> Text, executable code, code results, or other returned parts.
>
> **candidates\[].groundingMetadata.webSearchQueries** `string[]`
>
> Search queries issued when grounding metadata is returned.
>
> **candidates\[].groundingMetadata.searchEntryPoint.renderedContent** `string`
>
> Google-provided HTML and CSS for the search suggestions UI when returned.
>
> **candidates\[].groundingMetadata.groundingChunks** `object[]`
>
> Web or Maps sources returned for the response.
>
> **candidates\[].groundingMetadata.groundingSupports** `object[]`
>
> Links generated text segments to grounding sources when returned.
>
> **candidates\[].content.parts\[].executableCode** `object`
>
> Code returned when `codeExecution` is enabled and the model selects code execution.
>
> **candidates\[].content.parts\[].codeExecutionResult** `object`
>
> Execution outcome and output returned after code execution.
>
> **usageMetadata.toolUsePromptTokenCount** `integer`
>
> Tokens used for tool context when this metric is reported.
>
> **responseId** `string`
>
> Response identifier.

## Common optional request fields

**systemInstruction** `object`

Text-only system instruction with a `parts` array.

**generationConfig.stopSequences** `string[]`

Up to five strings that stop generation when encountered.

**safetySettings** `object[]`

Safety thresholds applied by harm category.

**safetySettings\[].category** `string`

Supported category, such as `HARM_CATEGORY_HATE_SPEECH` or `HARM_CATEGORY_DANGEROUS_CONTENT`.

**safetySettings\[].threshold** `string`

Blocking threshold, such as `BLOCK_MEDIUM_AND_ABOVE`, `BLOCK_ONLY_HIGH`, or `BLOCK_NONE`.

## Error responses

**error.code** `integer`

HTTP-compatible error code.

**error.message** `string`

Human-readable error description.

**error.status** `string`

Canonical error status.

> [!NOTE]
>
> A `400` response commonly indicates an invalid final conversation turn, an unsupported thinking level or tool, or an incomplete function response. A `401` response indicates an invalid API key; `429` indicates rate limiting.


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