{ "model_id": "google/gemini-4-hydrogen", "name": "Gemini 4 Hydrogen", "description": "Gemini 4 Hydrogen brings Gemini 4 agent and coding quality at Flash speed.", "task": "Text Generation", "tags": [ "LLM", "Multimodal", "Reasoning", "Agentic", "Coding" ], "context_length": 1048576, "max_output_tokens": 65536, "schema_version": "1.0.0", "pricing": { "Input tokens (per 1M)": 1.5, "Output tokens (per 1M)": 7.5, "Cached input tokens (per 1M)": 0.075 }, "examples": [ { "name": "Simple Question", "description": "Basic generateContent request", "input": { "contents": [ { "parts": [ { "text": "What are the key differences between optimistic and pessimistic concurrency control in distributed systems?" } ], "role": "user" } ] }, "output": { "text": "In distributed systems, concurrency control ensures that multiple nodes or clients accessing shared data do not leave it in an inconsistent state. Because nodes communicate over an unreliable network with non-zero latency, the choice between **Pessimistic Concurrency Control (PCC)** and **Optimistic Concurrency Control (OCC)** has significant implications for performance, fault tolerance, and scalability.\n\n---\n\n### 1. Core Philosophy & Execution Flow\n\n* **Pessimistic Concurrency Control (PCC):** Assumes conflicts are **likely**. A transaction must acquire locks (shared for reads, exclusive for writes) on data items across the relevant nodes *before* reading or modifying them. Other transactions trying to access the same data are blocked until the locks are released.\n * *Flow:* Acquire Locks \u2192 Read/Compute \u2192 Write \u2192 Commit & Release Locks.\n* **Optimistic Concurrency Control (OCC):** Assumes conflicts are **rare**. Transactions read data and perform computations locally without acquiring locks. Before committing, the system validates whether any data read by the transaction was modified by another transaction in the meantime. If a conflict is detected, the transaction aborts and retries.\n * *Flow:* Read/Compute (with versions/timestamps) \u2192 Validate \u2192 Write & Commit (or Abort & Retry).\n\n---\n\n### 2. Impact of Distributed Network Latency\n\n* **PCC (High Lock-Hold Duration):** In a distributed system, acquiring locks across multiple shards or replicas requires network round trips (e.g., Distributed Two-Phase Locking combined with Two-Phase Commit). While waiting for network responses or client computation, locks remain held, stalling other nodes and severely limiting throughput\u2014especially across wide-area networks (WANs).\n* **OCC (Reduced Blocking):** Because no locks are held during the read and compute phases, slow clients or high network latency during execution do not block other transactions. Network coordination is concentrated at the commit/validation phase (often via Compare-And-Swap, version checks, or distributed consensus).\n\n---\n\n### 3. Failure Modes & Fault Tolerance\n\n* **PCC (Deadlocks & Orphaned Locks):**\n * **Distributed Deadlocks:** Transaction A on Node 1 holds Lock X and waits for Lock Y on Node 2, while Transaction B holds Lock Y and waits for Lock X. Detecting cycles across nodes requires expensive global wait-for graphs or conservative lock timeouts.\n * **Node/Client Crashes:** If a client acquires a distributed lock and crashes (or gets partitioned), the resource remains locked indefinitely unless the system uses **leases** (time-bounded locks), which introduce clock-skew risks.\n* **OCC (Cascading Aborts & Starvation):**\n * **Deadlock-Free:** Because transactions never wait on locks, distributed deadlocks cannot occur.\n * **Wasted Work & Livelock:** If a node crashes mid-transaction, no cleanup of locks is needed. However, under heavy contention, long-running transactions may repeatedly fail validation and restart (starvation), wasting CPU and network bandwidth.\n\n---\n\n### 4. Performance Under Contention\n\n| Workload | Pessimistic (PCC) | Optimistic (OCC) |\n| :--- | :--- | :--- |\n| **Low Contention** | **Slower.** Pays the network and coordination tax of acquiring/releasing locks even when no conflicts exist. | **Faster.** Minimal coordination overhead; transactions execute unimpeded and usually pass validation. |\n| **High Contention** | **More Predictable.** Queues conflicting transactions orderly via locks, avoiding wasted computation and retry storms. | **Degrades Severely.** High abort rates cause retry storms, amplifying network traffic and reducing effective throughput. |\n\n---\n\n### 5. Common Distributed Implementations\n\n* **PCC:**\n * Distributed Lock Managers (e.g., using etcd, ZooKeeper, or Chubby with fencing tokens and leases).\n * Strict Two-Phase Locking (2PL) combined with Two-Phase Commit (2PC) in traditional distributed SQL databases.\n* **OCC:**\n * Version numbers / ETags with conditional writes (e.g., DynamoDB `ConditionExpression`, HTTP `If-Match`, S3 conditional puts).\n * Timestamp-based validation and Multi-Version Concurrency Control (MVCC) combined with validation phases (used in systems like Google Percolator or read-write paths of some distributed NewSQL databases).\n\n---\n\n### Summary Table\n\n| Dimension | Pessimistic (PCC) | Optimistic (OCC) |\n| :--- | :--- | :--- |\n| **Assumption** | Conflicts are frequent | Conflicts are rare |\n| **Conflict Detection** | Prevented upfront via locking | Detected at commit time via validation |\n| **Conflict Resolution** | Blocking / Waiting | Abort and retry |\n| **Deadlock Risk** | Yes (requires detection or timeouts) | No |\n| **Crash Impact** | Dangerous if locks aren't lease-based | Benign (uncommitted state is discarded) |\n| **Best Suited For** | Hot data, financial ledgers, high-contention writes, expensive rollbacks | Read-heavy workloads, geographically distributed clients, low-contention updates |\n\n*(Note: Many modern distributed databases\u2014such as CockroachDB or Google Spanner\u2014use **hybrid** approaches, combining MVCC so reads don't block writes, alongside locking or timestamp ordering for concurrent writes.)*" }, "raw_response": { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "In distributed systems, concurrency control ensures that multiple nodes or clients accessing shared data do not leave it in an inconsistent state. Because nodes communicate over an unreliable network with non-zero latency, the choice between **Pessimistic Concurrency Control (PCC)** and **Optimistic Concurrency Control (OCC)** has significant implications for performance, fault tolerance, and scalability.\n\n---\n\n### 1. Core Philosophy & Execution Flow\n\n* **Pessimistic Concurrency Control (PCC):** Assumes conflicts are **likely**. A transaction must acquire locks (shared for reads, exclusive for writes) on data items across the relevant nodes *before* reading or modifying them. Other transactions trying to access the same data are blocked until the locks are released.\n * *Flow:* Acquire Locks \u2192 Read/Compute \u2192 Write \u2192 Commit & Release Locks.\n* **Optimistic Concurrency Control (OCC):** Assumes conflicts are **rare**. Transactions read data and perform computations locally without acquiring locks. Before committing, the system validates whether any data read by the transaction was modified by another transaction in the meantime. If a conflict is detected, the transaction aborts and retries.\n * *Flow:* Read/Compute (with versions/timestamps) \u2192 Validate \u2192 Write & Commit (or Abort & Retry).\n\n---\n\n### 2. Impact of Distributed Network Latency\n\n* **PCC (High Lock-Hold Duration):** In a distributed system, acquiring locks across multiple shards or replicas requires network round trips (e.g., Distributed Two-Phase Locking combined with Two-Phase Commit). While waiting for network responses or client computation, locks remain held, stalling other nodes and severely limiting throughput\u2014especially across wide-area networks (WANs).\n* **OCC (Reduced Blocking):** Because no locks are held during the read and compute phases, slow clients or high network latency during execution do not block other transactions. Network coordination is concentrated at the commit/validation phase (often via Compare-And-Swap, version checks, or distributed consensus).\n\n---\n\n### 3. Failure Modes & Fault Tolerance\n\n* **PCC (Deadlocks & Orphaned Locks):**\n * **Distributed Deadlocks:** Transaction A on Node 1 holds Lock X and waits for Lock Y on Node 2, while Transaction B holds Lock Y and waits for Lock X. Detecting cycles across nodes requires expensive global wait-for graphs or conservative lock timeouts.\n * **Node/Client Crashes:** If a client acquires a distributed lock and crashes (or gets partitioned), the resource remains locked indefinitely unless the system uses **leases** (time-bounded locks), which introduce clock-skew risks.\n* **OCC (Cascading Aborts & Starvation):**\n * **Deadlock-Free:** Because transactions never wait on locks, distributed deadlocks cannot occur.\n * **Wasted Work & Livelock:** If a node crashes mid-transaction, no cleanup of locks is needed. However, under heavy contention, long-running transactions may repeatedly fail validation and restart (starvation), wasting CPU and network bandwidth.\n\n---\n\n### 4. Performance Under Contention\n\n| Workload | Pessimistic (PCC) | Optimistic (OCC) |\n| :--- | :--- | :--- |\n| **Low Contention** | **Slower.** Pays the network and coordination tax of acquiring/releasing locks even when no conflicts exist. | **Faster.** Minimal coordination overhead; transactions execute unimpeded and usually pass validation. |\n| **High Contention** | **More Predictable.** Queues conflicting transactions orderly via locks, avoiding wasted computation and retry storms. | **Degrades Severely.** High abort rates cause retry storms, amplifying network traffic and reducing effective throughput. |\n\n---\n\n### 5. Common Distributed Implementations\n\n* **PCC:**\n * Distributed Lock Managers (e.g., using etcd, ZooKeeper, or Chubby with fencing tokens and leases).\n * Strict Two-Phase Locking (2PL) combined with Two-Phase Commit (2PC) in traditional distributed SQL databases.\n* **OCC:**\n * Version numbers / ETags with conditional writes (e.g., DynamoDB `ConditionExpression`, HTTP `If-Match`, S3 conditional puts).\n * Timestamp-based validation and Multi-Version Concurrency Control (MVCC) combined with validation phases (used in systems like Google Percolator or read-write paths of some distributed NewSQL databases).\n\n---\n\n### Summary Table\n\n| Dimension | Pessimistic (PCC) | Optimistic (OCC) |\n| :--- | :--- | :--- |\n| **Assumption** | Conflicts are frequent | Conflicts are rare |\n| **Conflict Detection** | Prevented upfront via locking | Detected at commit time via validation |\n| **Conflict Resolution** | Blocking / Waiting | Abort and retry |\n| **Deadlock Risk** | Yes (requires detection or timeouts) | No |\n| **Crash Impact** | Dangerous if locks aren't lease-based | Benign (uncommitted state is discarded) |\n| **Best Suited For** | Hot data, financial ledgers, high-contention writes, expensive rollbacks | Read-heavy workloads, geographically distributed clients, low-contention updates |\n\n*(Note: Many modern distributed databases\u2014such as CockroachDB or Google Spanner\u2014use **hybrid** approaches, combining MVCC so reads don't block writes, alongside locking or timestamp ordering for concurrent writes.)*", "thoughtSignature": "AY89a1/V6+o/UuSQJtg1F89g9uBdMxhm3Dth//Y3tyKexkr3aIzRZNfypQbWdLh/XBiHk+6z4I2lwsmA/g0j/QYAljrP/V6M8He0nPi6Wl60DmCEnkCQAzpFUPFpHk/QFINah4ijg1W5XgtiCCNNHtFcfnLl5Wetn83TGNEPBrum7GFP1gTjcrkvaAk+G6esSpllIl5SfhbOfcOI+BAH4o5ht0WUxpNc4qvkT6FM6gZtv7hQ3rz5nLvBzirjU8/tn/Skx0wrjOiyODse17RPMuUPTzEPB6kpWpgI1/dabDmyWJz+a3tNelWQ9ZC8kyFxwnm6/7OH3XALJEOylPSokOQ5n+r7hSIryYletsruNRl6qxR02j2zHogYWIgq3AbrvXd3TauCwMqBAffBQMitHbaQJCJewLVy/gdvCUEgpPPhvV2Y2uH1oDA8W69L4AMHMgLl0qOQ6w056YOuhDqKeFY5NPMAjD++S7O4qLPq8IzZivDE/4vyObJC2hv+MJejxzZ2nkuzMFk898TPl00N8KplWvGFu2xVBKe9fBoPIpZItvBhoq4DPq0tF5ai/PdtVyI3MGRRozxLCdDX7k6mK88CZC89Ssr8/sEl4XD34eDPEYRvoeOoIAmkWO8ZyyFcY+Sr5/dP3NQxNopxkJhduFokUmdKY15wxNbAJFKEz4qT63wxu392HrnNokC6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l9vttveuWoGCAM5Zkrafc+8SlaNAL5xvaCM9jWhLDj0xbpdrYaq4IzqYdh7ttCEpLbPRS0uyiIbeaAuGvlfRjD4kBYiby9mXpAnUoVOdgX1B6c0odZfB5caXbeTFcRcDU=" } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 46, "candidatesTokenCount": 1120, "totalTokenCount": 1987, "trafficType": "ON_DEMAND", "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 46 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 1120 } ], "thoughtsTokenCount": 821 }, "modelVersion": "gemini-4-hydrogen", "createTime": "2026-11-13T00:03:49.781393Z", "responseId": "5VP2atHYL-aA3dAPvqmP8A0" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'google/gemini-4-hydrogen',\n {\n contents: [\n {\n parts: [\n {\n text: 'What are the key differences between optimistic and pessimistic concurrency control in distributed systems?',\n },\n ],\n role: 'user',\n },\n ],\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-4-hydrogen\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"What are the key differences between optimistic and pessimistic concurrency control in distributed systems?\"\n }\n ],\n \"role\": \"user\"\n }\n ]\n }\n}'" } ] }, { "name": "Agentic Coding", "description": "Coding task with a system instruction", "input": { "contents": [ { "parts": [ { "text": "Write a Python function that merges two sorted lists into one sorted list." } ], "role": "user" } ], "systemInstruction": { "parts": [ { "text": "You are an expert software engineering agent. Write concise, correct, well-documented code." } ] } }, "output": { "text": "```python\nfrom typing import TypeVar\n\nT = TypeVar(\"T\")\n\n\ndef merge_sorted_lists(list1: list[T], list2: list[T]) -> list[T]:\n \"\"\"Merge two sorted lists into a single sorted list.\n\n Uses a two-pointer approach to combine the lists in linear time\n while preserving the sorted order.\n\n Args:\n list1: The first sorted list.\n list2: The second sorted list.\n\n Returns:\n A new sorted list containing all elements from both input lists.\n \"\"\"\n merged: list[T] = []\n i, j = 0, 0\n\n while i < len(list1) and j < len(list2):\n if list1[i] <= list2[j]:\n merged.append(list1[i])\n i += 1\n else:\n merged.append(list2[j])\n j += 1\n\n # Append any remaining elements from either list\n if i < len(list1):\n merged.extend(list1[i:])\n if j < len(list2):\n merged.extend(list2[j:])\n\n return merged\n```\n\n### Example Usage\n```python\nprint(merge_sorted_lists([1, 3, 5], [2, 4, 6])) # [1, 2, 3, 4, 5, 6]\nprint(merge_sorted_lists([], [1, 2, 3])) # [1, 2, 3]\nprint(merge_sorted_lists([1, 2, 2], [2, 3])) # [1, 2, 2, 2, 3]\n```\n\n### Complexity\n- **Time Complexity:** $O(n + m)$, where $n$ and $m$ are the lengths of `list1` and `list2`.\n- **Space Complexity:** $O(n + m)$ for the returned merged list." }, "raw_response": { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "```python\nfrom typing import TypeVar\n\nT = TypeVar(\"T\")\n\n\ndef merge_sorted_lists(list1: list[T], list2: list[T]) -> list[T]:\n \"\"\"Merge two sorted lists into a single sorted list.\n\n Uses a two-pointer approach to combine the lists in linear time\n while preserving the sorted order.\n\n Args:\n list1: The first sorted list.\n list2: The second sorted list.\n\n Returns:\n A new sorted list containing all elements from both input lists.\n \"\"\"\n merged: list[T] = []\n i, j = 0, 0\n\n while i < len(list1) and j < len(list2):\n if list1[i] <= list2[j]:\n merged.append(list1[i])\n i += 1\n else:\n merged.append(list2[j])\n j += 1\n\n # Append any remaining elements from either list\n if i < len(list1):\n merged.extend(list1[i:])\n if j < len(list2):\n merged.extend(list2[j:])\n\n return merged\n```\n\n### Example Usage\n```python\nprint(merge_sorted_lists([1, 3, 5], [2, 4, 6])) # [1, 2, 3, 4, 5, 6]\nprint(merge_sorted_lists([], [1, 2, 3])) # [1, 2, 3]\nprint(merge_sorted_lists([1, 2, 2], [2, 3])) # [1, 2, 2, 2, 3]\n```\n\n### Complexity\n- **Time Complexity:** $O(n + m)$, where $n$ and $m$ are the lengths of `list1` and `list2`.\n- **Space Complexity:** $O(n + m)$ for the returned merged list.", "thoughtSignature": "AY89a18K+RfRuMGvBUZuuFZG6pLQI+YVqxyWyh6wpvNm/eE9rctLkx1fQFCMTwJRBg3sz6yTscGMrryBzRdyrrYZI2P/TSGCiYfBqc9elxTtGcjyI4kTqzL4OVehNMun70VHHMVh1FKbGyVkzqqQ6UPsoqUJdk3EWvN/MkzGdLiGWV7THyACKeP3hhUJ62BfPcRlBVxa33O6/pZMT4qKY6qbDRNL+Imwk1lvwF19/i63DnKor+nhL6PSpURvB50xpgloNsvvbR0OjD5K4JOKHz5TeRoi4ZMLGZsa81/toXHpVOBdCMFSCPH6iYuAjXmewEEh7QrnRh69tx/NWfknGNNnkV1dvnanxDndG5TmJ/ycnnyg9N37l3ormT+sw+ndeRbYpbPU/vfEE/v7ollJ3ZkZ0q2mG/xRsLyyLZatbAhWlvlqPF4Xl4vnLg==" } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 68, "candidatesTokenCount": 457, "totalTokenCount": 577, "trafficType": "ON_DEMAND", "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 68 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 457 } ], "thoughtsTokenCount": 52 }, "modelVersion": "gemini-4-hydrogen", "createTime": "2026-11-13T00:04:02.561753Z", "responseId": "8lP2atmkIrqH3dAPlNLEoA0" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'google/gemini-4-hydrogen',\n {\n contents: [\n {\n parts: [\n { text: 'Write a Python function that merges two sorted lists into one sorted list.' },\n ],\n role: 'user',\n },\n ],\n systemInstruction: {\n parts: [\n {\n text: 'You are an expert software engineering agent. Write concise, correct, well-documented code.',\n },\n ],\n },\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-4-hydrogen\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"Write a Python function that merges two sorted lists into one sorted list.\"\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are an expert software engineering agent. Write concise, correct, well-documented code.\"\n }\n ]\n }\n }\n}'" } ] }, { "name": "Multi-turn Conversation", "description": "Continuing a multi-step coding conversation, typical of an agentic loop", "input": { "contents": [ { "parts": [ { "text": "I have a bug where my recursive fibonacci function is too slow for n=40." } ], "role": "user" }, { "parts": [ { "text": "That's expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?" } ], "role": "model" }, { "parts": [ { "text": "Show me the memoized version." } ], "role": "user" } ] }, "output": { "text": "Here is the memoized version in Python using a dictionary to store already-computed results:\n\n```python\ndef fib(n, memo={}):\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n \n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n```\n\n*(Note: Using a mutable default argument like `memo={}` is fine here since you want the cache to persist across calls, though if you want a fresh cache per top-level call, initialize `memo=None` and set `memo = {}` inside the function or use a wrapper.)*\n\nIf you are using Python 3.9+, you can also use the built-in `@cache` decorator to do the exact same thing automatically:\n\n```python\nfrom functools import cache\n\n@cache\ndef fib(n):\n if n <= 1:\n return n\n return fib(n - 1) + fib(n - 2)\n```\n\nThis brings the time complexity down from $O(2^n)$ to $O(n)$, so `fib(40)` will run almost instantaneously. Let me know if you need this in a different language." }, "raw_response": { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "Here is the memoized version in Python using a dictionary to store already-computed results:\n\n```python\ndef fib(n, memo={}):\n if n in memo:\n return memo[n]\n if n <= 1:\n return n\n \n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n```\n\n*(Note: Using a mutable default argument like `memo={}` is fine here since you want the cache to persist across calls, though if you want a fresh cache per top-level call, initialize `memo=None` and set `memo = {}` inside the function or use a wrapper.)*\n\nIf you are using Python 3.9+, you can also use the built-in `@cache` decorator to do the exact same thing automatically:\n\n```python\nfrom functools import cache\n\n@cache\ndef fib(n):\n if n <= 1:\n return n\n return fib(n - 1) + fib(n - 2)\n```\n\nThis brings the time complexity down from $O(2^n)$ to $O(n)$, so `fib(40)` will run almost instantaneously. Let me know if you need this in a different language.", "thoughtSignature": "AY89a18H8Khrq9Yj7SsNNS6g4HVYt0H7fZMEL8mmJ7f0YdQSdeRcLw+kRrXLZub+RPHD5I4gGPxjHW09m8RUkuUoo2un+KRqC5VoVbitATuiXaeslC+dUC1G6SOqxm60+3FvyuRkB0rhS+a5sE2sXZkz4RucjXod3GffHCeUekvTyi1lCHbif7auicgE6Qey0+ni1CZbYnHx9cnvAjqMSvCtHvmAo4nRPU2AlAq/68hKL21ap3azNdjOZpR1HZAR3ow6ZIhXbuLFj94WeS+pBbHEvQM4NR0wvqDCMSeuHLkPidFVDEq1NeSENwIoGFTj99TGA8QYDVYxpJzfAohBVe/Cqq2AN1t76WYnrazEgVBzannxiW3ouC4mHaQz+bnFIKgo+0Rmh6oWCtC8+XBFg94oOerbLm1DkcHK2Y4hT2P44oTOdbSlWUgIDRn/3PQxKbXFqDAXsjM/kZVegkNhEztKSsGDoTtP2sfI57lxujXBBgMxDEqXPTDKyz8IV+OwutgrISCaRaEGYuvmY3Vnq6he+OACI1bCMdttcB1Z4TQhszGacTZEAg8Ht76YE/PdF39Yqlg3sTrBkOgPDIhxJHcPEehPAyJd1kj51gdit6z8pj545XacbawpfjvBWsFnJTMzKcK7nubo1GKLTU2vwN09O+5HGLm3SX70R3pa+VYYQZrKRyvTOFttENYWyFlc/lgn5dX2GGw6xkU2FVmw2mgJ01Mw8LUZ5pgFor1aatKmrVTC4eW5F5sikTHTLvpF5fZ0kcuWLrcX4A8iLPy9bJus7ijv8mtxXCatOqF9mHzyHvIda1e3bocMP8WNmppetEPlPinczbiCah/BokCgGwbKkxCGDRfhm1BRcvg+j0KzEbjXJ7YwrNvlnEo9iNUTVvdW+zXnfWbvAEZ+YE9oKAo3Yuk2vw6j8eUwD7qvHCoSwkSTBQTyTfsn1X/ssdi0fzh+aiYujpYQDi8NRTV2eUCy+RMyeRC7d/eMCfNL9OkETEP64WMzSlcr7sKe2VNUreeKu1PK9I/JSQOlHKZaJPN+zJ61dh+ZSR+S1HS7Eg3G5koImHjBNvELFpNBcQgbVibmISkESuYJhKQmwt68esOqSU0OWTEf3cWFoAyYN8UOiMVIfV8eyoS473Fp3rGeXuVCoSXPel/APiL7y8SaqzfrDbNEkwO8ybksGUi1AbuEDRNZ8aLC/f6dZu1WKq5fVJxKhLSaeo9cxysrvH8aESVvhOHUSlYaAxNeHMu5ZDxGOfNnU5yKiR8gUhwsKrY1YRIPmS8MPAbeXq0cO8EmzrNXQNGGXoWNjt9uA7fwUzE6h1EHMsyxLe0uLtfkFqrNrCkQFCoYquS5U2BvFY198+76vSYXOmmfSH63xwK5Fp7yeoAljKvY7+0LXIBmNv/z91gye1No7ucdQ2YvJJDa4J9ad1KulJJLVOHk8cL2NxKhNomCw/e750Eqa7qKpoQKVcHOKaEs5D0zAIkOCAL6aFhMFbEtibWw9r3Hdyiq3M6rx8mwaV4fsS+If8nnamUIx1pu6VHahsAvtksOKw==" } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 101, "candidatesTokenCount": 284, "totalTokenCount": 642, "trafficType": "ON_DEMAND", "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 101 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 284 } ], "thoughtsTokenCount": 257 }, "modelVersion": "gemini-4-hydrogen", "createTime": "2026-11-13T00:04:06.452258Z", "responseId": "9lP2aqLNG7KC3dAPxpGXyA8" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'google/gemini-4-hydrogen',\n {\n contents: [\n {\n parts: [{ text: 'I have a bug where my recursive fibonacci function is too slow for n=40.' }],\n role: 'user',\n },\n {\n parts: [\n {\n text: \"That's expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?\",\n },\n ],\n role: 'model',\n },\n { parts: [{ text: 'Show me the memoized version.' }], role: 'user' },\n ],\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-4-hydrogen\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"I have a bug where my recursive fibonacci function is too slow for n=40.\"\n }\n ],\n \"role\": \"user\"\n },\n {\n \"parts\": [\n {\n \"text\": \"That'\\''s expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?\"\n }\n ],\n \"role\": \"model\"\n },\n {\n \"parts\": [\n {\n \"text\": \"Show me the memoized version.\"\n }\n ],\n \"role\": \"user\"\n }\n ]\n }\n}'" } ] }, { "name": "Spatial Reasoning", "description": "A reasoning-heavy puzzle with the thinking level set to HIGH", "input": { "contents": [ { "parts": [ { "text": "A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?" } ], "role": "user" } ], "generationConfig": { "thinkingConfig": { "thinkingLevel": "HIGH" } } }, "output": { "text": "When a cube is cut into 27 equal smaller cubes ($3 \\times 3 \\times 3$), the cubes with **exactly two red faces** are the ones located along the edges, excluding the corners. \n\n* A cube has **12 edges**.\n* On each edge of 3 smaller cubes, the 2 corner cubes have three red faces, leaving **1 middle cube** per edge with two red faces.\n\n$12 \\text{ edges} \\times 1 \\text{ cube per edge} = \\mathbf{12}$\n\nThere are **12** smaller cubes with exactly two red faces." }, "raw_response": { "candidates": [ { "content": { "role": "model", "parts": [ { "text": "When a cube is cut into 27 equal smaller cubes ($3 \\times 3 \\times 3$), the cubes with **exactly two red faces** are the ones located along the edges, excluding the corners. \n\n* A cube has **12 edges**.\n* On each edge of 3 smaller cubes, the 2 corner cubes have three red faces, leaving **1 middle cube** per edge with two red faces.\n\n$12 \\text{ edges} \\times 1 \\text{ cube per edge} = \\mathbf{12}$\n\nThere are **12** smaller cubes with exactly two red faces.", "thoughtSignature": "AY89a1/jbphySqF95wQbjfNJxFENVKDTW7BFBd53L2yAGu3sMtum5II6q3tt1q52BxQWPQaGcgwJfeAmL42TxNyfiebY0WrWYhycKhTmbDaZoVnEYQsGZnQNu2zl3cNnF9Buwu16oERQBcLT7LNKNiBls7E8VGgECSvSqt8OhVrShx4WqBRL1l/3kTdA2nquXNji24guawQav2KrZgGbnSTe4mzraAZst2O1HEv08mL/ZTQsQZR8aVpenkDkKGoCGX0nnOfqV1n/RmVBTkbteiijDgc1F6xl/S28qB4UINJrPNApxgIgsHOga1K4MtMwFEMJ7BxoNN8r04l/F75i1J/SqwyPE1t4bQaHG4Gr9+QuoZEoLp9O3f3XrVWRTdmIvClXUODHbXN4N4mwW2t2FZ/82qUtDBOX/vjDfRoGIfjmq0k3yyDOM6Y+4io9r3/f0Tn0OPzVW6S4qd2X5gssKIj+Kd7A62M4pADdWAz3doC6xqrddLJI2p1DqR8V7LxPf6dhU6zmiEYdUUckWpC6kTaiT4gcQYjYZqDvqHeJEayqwT2eir8t4yolBIJsnwn+c2kCarmNAnjNl894KNNNsZvlYBshL1ksPvkP9cqzR5tWbQ+5t0AGDmWS3oseL0VmwkP94kP4T6ybOo2cG1YsnV8mQhRAPGNQE4wtSl/GtOfN5asRJuZE+vbxap+Z450C2Hg+Tigw+K0OzYspTxfOsPOu7n26HYFbYqX2/6K1ru4CL9dvrLmW5QMgIjB084xOGnipDrezUhRdbHBP2iQm7zdfpiDBIGI6unAA1BVwNpXqZ60C5W6BocYZpBHpTC7sP2bmglrB0X8GW+dgJae6ag8AESMGfL+NWp6m6tEgcGjRn9hfAqtFw4hfw+YgMev26Uw37LyIytKOwjhaaqK/6LTBmP2+puLSii8cxL/DtnIhX/yNlstAcc8JaVM6FLz5wnTVxpnH+IcuephR5fZIFL9pIyveetiiuX/aFSKQILL1NLhcKqDKhS9okZR4Ft68uTLHuM4ewZ/e02R1m/IEsUlnbBAWjqh4jZPJiFWEMXtTnnVH4X6R371H4oFWWGIdHs1ETEAq/bD3vjkk/Ov4RvHUxHXhuCQ=" } ] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 62, "candidatesTokenCount": 135, "totalTokenCount": 460, "trafficType": "ON_DEMAND", "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 62 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 135 } ], "thoughtsTokenCount": 263 }, "modelVersion": "gemini-4-hydrogen", "createTime": "2026-11-13T00:04:10.338909Z", "responseId": "-lP2at3XFMqg3dAP9uPQiA4" }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'google/gemini-4-hydrogen',\n {\n contents: [\n {\n parts: [\n {\n text: 'A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?',\n },\n ],\n role: 'user',\n },\n ],\n generationConfig: { thinkingConfig: { thinkingLevel: 'HIGH' } },\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-4-hydrogen\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?\"\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"thinkingConfig\": {\n \"thinkingLevel\": \"HIGH\"\n }\n }\n }\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": true, "zdr_comment": null, "external_info": "https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-hydrogen", "terms": "https://ai.google.dev/gemini-api/terms", "cover_image_url": null, "metadata": { "Output per request": "65,536 tokens (up to 1,048,576 with long decodes)", "Thinking levels": "low, medium, high (set explicitly)" }, "request_formats": [ "chat-completions" ], "provider_id": "google", "providers": null, "provider_details": [ { "id": "google-vertex-ai", "pricing": { "input_tokens": 1.5, "output_tokens": 7.5, "input_cached_tokens": 0.075 } } ], "model_providers": [ { "provider": "google-vertex-ai", "pricing": null, "rates": null } ], "banner": null, "pinned": false, "created_at": "2026-11-13 23:26:40", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "oneOf": [ { "type": "object", "properties": { "contents": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "enum": [ "user", "model" ] }, "parts": { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string" } }, "additionalProperties": {} } } }, "required": [ "parts" ], "additionalProperties": {} } }, "systemInstruction": { "type": "object", "properties": { "parts": { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string" } }, "additionalProperties": {} } } }, "required": [ "parts" ], "additionalProperties": {} }, "generationConfig": { "type": "object", "properties": { "temperature": { "type": "number" }, "topP": { "type": "number" }, "topK": { "type": "number" }, "maxOutputTokens": { "type": "number" }, "candidateCount": { "type": "number" }, "stopSequences": { "type": "array", "items": { "type": "string" } }, "responseMimeType": { "type": "string" } }, "additionalProperties": {} }, "safetySettings": { "type": "array", "items": { "type": "object", "properties": { "category": { "type": "string" }, "threshold": { "type": "string" } }, "required": [ "category", "threshold" ], "additionalProperties": {} } }, "tools": { "type": "array", "items": {} }, "toolConfig": {} }, "required": [ "contents" ], "additionalProperties": {}, "title": "Generate Content" }, { "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "enum": [ "system", "developer", "user", "assistant", "tool" ] }, "content": { "anyOf": [ { "type": "string" }, { "type": "null" }, { "type": "array", "items": {} } ] } }, "required": [ "role" ], "additionalProperties": {} } }, "temperature": { "type": "number", "minimum": 0, "maximum": 2 }, "max_tokens": { "type": "number", "exclusiveMinimum": 0 }, "max_completion_tokens": { "type": "number", "exclusiveMinimum": 0 }, "top_p": { "type": "number", "minimum": 0, "maximum": 1 }, "frequency_penalty": { "type": "number", "minimum": -2, "maximum": 2 }, "presence_penalty": { "type": "number", "minimum": -2, "maximum": 2 }, "stream": { "type": "boolean" }, "stream_options": { "type": "object", "properties": { "include_usage": { "type": "boolean" } }, "additionalProperties": false }, "tools": { "type": "array", "items": {} }, "tool_choice": {}, "response_format": {}, "modalities": { "type": "array", "items": { "type": "string", "enum": [ "text", "audio" ] } }, "audio": { "type": "object", "properties": { "voice": { "type": "string", "enum": [ "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse" ] }, "format": { "type": "string", "enum": [ "wav", "mp3", "flac", "opus", "pcm16" ] } }, "additionalProperties": false }, "reasoning_effort": { "description": "Optional reasoning control; availability and accepted values are model-dependent.", "type": [ "string", "null" ] } }, "required": [ "messages" ], "additionalProperties": {}, "title": "Chat Completions" } ] }, "output": { "$schema": "https://json-schema.org/draft/2020-12/schema", "oneOf": [ { "type": "object", "properties": { "candidates": { "type": "array", "items": {} }, "usageMetadata": { "type": "object", "properties": { "promptTokenCount": { "type": "number" }, "candidatesTokenCount": { "type": "number" }, "totalTokenCount": { "type": "number" } }, "additionalProperties": {} }, "modelVersion": { "type": "string" } }, "additionalProperties": {}, "title": "Generate Content" }, { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string" }, "created": { "type": "number" }, "model": { "type": "string" }, "choices": { "type": "array", "items": { "type": "object", "properties": { "index": { "type": "number" }, "message": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": [ "string", "null" ] }, "tool_calls": { "anyOf": [ { "type": "array", "items": {} }, { "type": "null" } ] }, "audio": { "anyOf": [ { "type": "object", "properties": { "id": { "type": "string" }, "data": { "type": "string" }, "expires_at": { "type": "number" }, "transcript": { "type": "string" } }, "additionalProperties": {} }, { "type": "null" } ] } }, "required": [ "role" ], "additionalProperties": {} }, "finish_reason": { "type": [ "string", "null" ] } }, "required": [ "index", "message", "finish_reason" ], "additionalProperties": {} } }, "usage": { "type": "object", "properties": { "prompt_tokens": { "type": "number" }, "completion_tokens": { "type": "number" }, "total_tokens": { "type": "number" } }, "required": [ "prompt_tokens", "completion_tokens", "total_tokens" ], "additionalProperties": {} } }, "required": [ "id", "object", "created", "model", "choices" ], "additionalProperties": {}, "title": "Chat Completions" } ] } } }