# Gemini 4 Hydrogen

Use `gemini-4-hydrogen` with the native Gemini format. See [current rates](#current-rates). Gemini 4 Hydrogen uses the same request format as [Gemini 4 Argon](https://toklab.ai/docs/gemini-4-argon); Google's guide says moving between them needs only a model ID change.

## Model ID

| Model ID            | Context window                                         | Default effort |
| ------------------- | ------------------------------------------------------ | -------------- |
| `gemini-4-hydrogen` | 1,048,576 tokens, shared by input, thinking and output | `high`         |

Check `/v1/models` and the live rates for routes available to your key. The public gateway currently lists both `gemini-4-hydrogen` and `gemini-4-hydrogen:googlellm-vertext`; the examples use the bare model ID.

## Quick example

```bash
curl https://api.toklab.ai/v1beta/models/gemini-4-hydrogen:generateContent \
  -H "Authorization: Bearer $TOKLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Find the race condition in a retry loop that re-reads a balance before locking it."}]}],"generationConfig":{"thinkingConfig":{"thinkingLevel":"high"},"maxOutputTokens":65536}}'
```

```python
import json
import os
from urllib.request import Request, urlopen

body = {
    "contents": [{"role": "user", "parts": [{"text": "Find the race condition in a retry loop that re-reads a balance before locking it."}]}],
    "generationConfig": {"thinkingConfig": {"thinkingLevel": "high"}, "maxOutputTokens": 65536},
}
request = Request(
    "https://api.toklab.ai/v1beta/models/gemini-4-hydrogen:generateContent",
    data=json.dumps(body).encode(),
    headers={"Authorization": f"Bearer {os.environ['TOKLAB_API_KEY']}", "Content-Type": "application/json"},
    method="POST",
)
with urlopen(request, timeout=1200) as response:
    print(json.load(response))
```

```javascript
const response = await fetch(
  "https://api.toklab.ai/v1beta/models/gemini-4-hydrogen:generateContent",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.TOKLAB_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      contents: [{ role: "user", parts: [{ text: "Find the race condition in a retry loop that re-reads a balance before locking it." }] }],
      generationConfig: { thinkingConfig: { thinkingLevel: "high" }, maxOutputTokens: 65536 },
    }),
  },
);
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

```go
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
    "os"
    "time"
)

func main() {
    body := []byte(`{"contents":[{"role":"user","parts":[{"text":"Find the race condition in a retry loop that re-reads a balance before locking it."}]}],"generationConfig":{"thinkingConfig":{"thinkingLevel":"high"},"maxOutputTokens":65536}}`)
    req, err := http.NewRequest("POST", "https://api.toklab.ai/v1beta/models/gemini-4-hydrogen:generateContent", bytes.NewReader(body))
    if err != nil { panic(err) }
    req.Header.Set("Authorization", "Bearer " + os.Getenv("TOKLAB_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{Timeout: 20 * time.Minute}
    resp, err := client.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    out, err := io.ReadAll(resp.Body)
    if err != nil { panic(err) }
    fmt.Println(string(out))
}
```

The model belongs in the URL. `contents` is required. An answer includes native `candidates`, `finishReason` and `usageMetadata`; retain complete content parts, including `thoughtSignature`, for conversation history. Hard prompts can run for several minutes. Google recommends a 20-minute client timeout. Use streaming to receive output as it becomes available.

## Endpoints

| Operation          | Endpoint                                                              |
| ------------------ | --------------------------------------------------------------------- |
| JSON response      | `POST /v1beta/models/gemini-4-hydrogen:generateContent`               |
| Server-sent events | `POST /v1beta/models/gemini-4-hydrogen:streamGenerateContent?alt=sse` |

The [OpenAPI specification](https://toklab.ai/docs/gemini-4-hydrogen.openapi.json) includes every nested request and response schema. Optional fields use API defaults when omitted. The public native API preserves the submitted body for Gemini validation.

## Request parameters

The URL fixes the model to `gemini-4-hydrogen`. The request contract contains 11 top-level fields. Fields are optional unless marked required; omission differs from JSON `null`. Nullable arbitrary JSON is preserved where the official schema permits it.

| Field               | Type      | Required | Default and constraints                                                                                     |
| ------------------- | --------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| `contents`          | object\[] | Yes      | Nonempty conversation; each content has nonempty `parts`                                                    |
| `systemInstruction` | object    | No       | Text-only parts; no automatic user identity is inserted                                                     |
| `generationConfig`  | object    | No       | Generation parameters in the next table                                                                     |
| `tools`             | object\[] | No       | Function declarations and built-in tool configurations                                                      |
| `toolConfig`        | object    | No       | Function selection and retrieval configuration                                                              |
| `safetySettings`    | object\[] | No       | One setting per category; no duplicate categories                                                           |
| `serviceTier`       | string    | No       | `unspecified`, `standard`, `flex`, `priority`; ordinary processing is standard                              |
| `continuationToken` | string    | No       | Token returned with `finishReason: CONTINUATION`; resend the same request with it to continue a long answer |
| `labels`            | object    | No       | String values; lowercase keys/values, maximum 63 Unicode codepoints each                                    |
| `model`             | string    | No       | Optional resource name; the URL determines the actual model                                                 |
| `store`             | boolean   | No       | Generic request storage preference; model-specific effect unverified                                        |

Explicit context caching (`cachedContent` and `cachedContents` resources) is not supported on Gemini 4 Hydrogen. Implicit caching is on by default for prompts of at least 4,096 tokens.

### Generation parameters

| Field in `generationConfig`  | Type      | Default and constraints                                                                                                                                                                                                                                                            |
| ---------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxOutputTokens`            | integer   | Default 65,536, including thinking. Up to 1,048,576 minus input with continuation. Each streaming or non-streaming response supports up to 65,536 tokens; use continuation for longer output                                                                                       |
| `thinkingConfig`             | object    | `thinkingLevel`: `low`, `medium`, `high`, `xhigh` (default `high`); uppercase spellings accepted. `includeThoughts`: boolean, default false. Use `thinkingLevel`; the deprecated `thinkingBudget` maps to a level when supplied alone, and cannot be combined with `thinkingLevel` |
| `stopSequences`              | string\[] | Maximum five sequences                                                                                                                                                                                                                                                             |
| `responseMimeType`           | string    | Default `text/plain`; legacy JSON schema output requires `application/json`                                                                                                                                                                                                        |
| `responseSchema`             | object    | Official schema dialect; mutually exclusive with `responseJsonSchema`                                                                                                                                                                                                              |
| `responseJsonSchema`         | JSON      | JSON Schema; mutually exclusive with `responseSchema`                                                                                                                                                                                                                              |
| `responseFormat`             | object    | Text format configuration; `text.mimeType` and optional `text.schema`. Schema requires JSON MIME type                                                                                                                                                                              |
| `responseModalities`         | string\[] | Text only: `TEXT`; empty means text                                                                                                                                                                                                                                                |
| `mediaResolution`            | enum      | `MEDIA_RESOLUTION_UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` with the `MEDIA_RESOLUTION_` prefix                                                                                                                                                                                        |
| `seed`                       | integer   | Signed 32-bit value; model-specific deterministic behavior unverified                                                                                                                                                                                                              |
| `presencePenalty`            | number    | Generic field; model-specific effect/range unverified                                                                                                                                                                                                                              |
| `frequencyPenalty`           | number    | Generic field; model-specific effect/range unverified                                                                                                                                                                                                                              |
| `responseLogprobs`           | boolean   | Generic field; model-specific availability unverified                                                                                                                                                                                                                              |
| `logprobs`                   | integer   | 0–20; requires `responseLogprobs: true`; model support unverified                                                                                                                                                                                                                  |
| `enableEnhancedCivicAnswers` | boolean   | Generic field; model support unverified                                                                                                                                                                                                                                            |
| `enableAffectiveDialog`      | boolean   | Generic field; model support unverified                                                                                                                                                                                                                                            |
| `audioTranscriptionConfig`   | object    | Generic field; model-specific options unverified                                                                                                                                                                                                                                   |
| `translationConfig`          | object    | Generic field; model-specific options unverified                                                                                                                                                                                                                                   |

The [OpenAPI document](https://toklab.ai/docs/gemini-4-hydrogen.openapi.json) lists nested types, enums, required properties and documented bounds for every message. The schemas describe official parameters; they are not a TokLab request allowlist. Caller-supplied fields and values are preserved. A field accepted by the schema is not proof of support for every account. `minimal` thinking is not a listed level. Google says `temperature`, `topP`, `topK` and `candidateCount` are deprecated and should be removed; custom sampling values are ignored. If submitted in native JSON, they still pass through unchanged for the Gemini API to handle.

## Long decode

One Gemini 4 Hydrogen response returns up to 65,536 tokens when streaming and up to 65,536 tokens without streaming. To go further, set `maxOutputTokens` above 65,536 and continue the answer yourself:

1. Send the request. If the response ends with `finishReason: "CONTINUATION"`, read `candidates[0].continuationToken`.
2. Send the **same** request again with that value in the top-level `continuationToken` field. Do not append the partial output to `contents`; the token carries the model's state, including its thinking.
3. Repeat until `finishReason` is `STOP` or `MAX_TOKENS`.

```json
{
  "contents": [{"role": "user", "parts": [{"text": "Write a complete, rigorous proof of the prime number theorem."}]}],
  "generationConfig": {"thinkingConfig": {"thinkingLevel": "high"}, "maxOutputTokens": 262144},
  "continuationToken": "TOKEN_FROM_THE_PREVIOUS_RESPONSE"
}
```

A hop spent entirely on thinking can return empty text with `CONTINUATION`; that is normal progress. Each hop sends your prompt plus everything generated so far back to the model, so input tokens are counted again in every later hop. TokLab bills each hop as its own request. The Interactions API's server-side `background` mode is not part of this endpoint.

## Structured output

```json
{
  "contents": [{"parts": [{"text": "Return a JSON object with ok set to true."}]}],
  "generationConfig": {
    "thinkingConfig": {"thinkingLevel": "low"},
    "maxOutputTokens": 65536,
    "responseMimeType": "application/json",
    "responseJsonSchema": {
      "type": "object",
      "properties": {"ok": {"type": "boolean"}},
      "required": ["ok"]
    }
  }
}
```

The legacy `responseSchema` and `responseJsonSchema` fields cannot be used together. Both require `responseMimeType: "application/json"`. The newer `responseFormat.text` schema must likewise specify JSON. Use REST enum spellings (`APPLICATION_JSON` and `TEXT_PLAIN`) in that message. Requests pass through unchanged; media MIME types and arbitrary function JSON are not rewritten.

## Functions and built-in tools

Use `tools[].functionDeclarations` with a name and either `parameters` or `parametersJsonSchema`, not both. Function selection lives in `toolConfig.functionCallingConfig`; `allowedFunctionNames` requires `ANY` or `VALIDATED` and declared names.

Your application executes returned functions and supplies their results in the next conversation turn. Preserve each original `thoughtSignature`, function call and function response. Do not round numeric identifiers when serializing opaque function arguments.

Google lists Search, Maps, code execution, URL context, File Search and Computer Use for this model. File Search resources require access under the credentials serving the request. Native MCP configuration appears in the generic schema, but its availability for this model is not established. Check the official restrictions for each tool before combining it with media. With grounding, Google counts internal tool instructions and function declarations as input tokens.

## Multimodal input and safety

A `contents[].parts[]` item contains exactly one payload: text, inline media, a file reference, a function call/response, or an execution part. It may also carry a signature or media metadata. Input supports text, images, audio, video and PDFs; output is text only. The model has no image or audio generation and no Live API.

For inline bytes, use `inlineData.mimeType` and base64 `data`. For file references, use `fileData.mimeType` and `fileUri`. A syntactically valid URL is not proof the model can retrieve it. Video metadata can specify start/end offsets and a positive `fps` no greater than 24. Agentic video understanding is selected per part with `mediaProcessing: "AGENTIC"` next to the video's `fileData` or `inlineData`; static processing is the default. `videoMetadata` holds only `startOffset`, `endOffset` and `fps`.

Safety settings use the official native format and pass through the API unchanged.

## JSON responses and streaming

`generateContent` returns native JSON. `streamGenerateContent?alt=sse` emits native JSON in SSE `data:` events. Important fields include `candidates[].content.parts`, `finishReason`, `continuationToken`, `safetyRatings`, `groundingMetadata`, `promptFeedback`, `modelVersion`, `responseId` and `usageMetadata`.

Retain complete native content in conversation history. Thinking summaries are not the same as thought signatures. A disconnect does not prove generation failed or completed; inspect the partial result and account record before sending another request. Stream usage is cumulative, so use the latest counters instead of summing every chunk.

## Usage and pricing

`promptTokenCount` includes cached input. `cachedContentTokenCount` is charged at the cached-input rate, rather than charged again as uncached input. Billable output includes `candidatesTokenCount` plus `thoughtsTokenCount`. Hydrogen defaults to high thinking. Set the level explicitly when comparing its usage with another model.

There is no context-length price step for this model. Current TokLab prices use Standard token rates; Flex discounts and Priority surcharges have not been configured for this integration. Support for those processing tiers still requires verification. Google Search grounding can add per-query charges beyond token usage; check tool pricing before enabling it. Failed requests are not charged. See the [current rates](https://toklab.ai/docs/gemini-4-hydrogen#current-rates).

## Account groups

The Default tier uses `gemini-4-hydrogen`. Use `gemini-4-hydrogen:googlellm-vertext` to select that additional tier explicitly. Availability follows `/v1/models` for your key. The API also accepts an explicit header:

```http
X-SeedRouter-Group: GROUP_NAME
```

The chosen group determines the price and available capacity; an explicit selection does not silently switch to another group. Omit the header or use `auto` to keep the API key's default behavior.

Check your API key's available groups without generating a response:

```bash
curl "https://api.toklab.ai/api/seedrouter/llm/groups?model=gemini-4-hydrogen" \
  -H "Authorization: Bearer YOUR_SEEDROUTER_KEY"
```

## Verification status

Official documentation was checked on November 13, 2026. On that date, three single-attempt paid checks through TokLab passed: structured JSON with low thinking, SSE with xhigh thinking, and a declared function call with low thinking. Reported input, output and thinking tokens matched the recorded charges at the published rates. Media understanding, grounding, Computer Use, continuation/long decode, other generic fields and processing tiers remain unverified. These checks do not establish comparative quality or latency.

## References

* [Google model specification](https://aistudio.google.com/docs/models/gemini-4-hydrogen)
* [What's new in Gemini 4 Hydrogen](https://aistudio.google.com/docs/whats-new-gemini-4-hydrogen)
* [Long decode with generateContent](https://aistudio.google.com/docs/long-decode?generate-content=true)
* [Thinking](https://aistudio.google.com/docs/thinking)
* [Pricing](https://aistudio.google.com/docs/pricing#gemini-4-hydrogen)
* [GenerateContent REST reference](https://ai.google.dev/api/generate-content)

## Pricing

Every rate this model is billed at, read live from the price list billing uses. A tier applies when its condition matches, checked top to bottom.

### gemini-4-hydrogen

| Input (per 1M tokens) | Output (per 1M tokens) | Cache read (per 1M tokens) |
| --- | --- | --- |
| $0.675 | $3.375 | $0.03375 |

Price tier google llm vertext (`gemini-4-hydrogen:googlellm-vertext`):

| Input (per 1M tokens) | Output (per 1M tokens) | Cache read (per 1M tokens) |
| --- | --- | --- |
| $1.05 | $5.25 | $0.0525 |
