---
description: Gemini 3.6 Flash provides sustained frontier-level intelligence optimized for real-world tasks at a higher speed and lower cost, excelling at code generation, agentic execution, and spatial reasoning.
title: Gemini 3.6 Flash
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content ](#main-content) 

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further. 

![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg) 

#  Gemini 3.6 Flash 

 Text Generation • Google 

Copy as Markdown | [ View as Markdown ](https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/index.md) | [ Agent setup ](https://developers.cloudflare.com/agent-setup/) 

` google/gemini-3.6-flash ` 

* Third-party

Gemini 3.6 Flash provides sustained frontier-level intelligence optimized for real-world tasks at a higher speed and lower cost, excelling at code generation, agentic execution, and spatial reasoning.

| Model Info                                                                  |                                                                                                                            |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/glossary/) | 1,048,576 tokens                                                                                                           |
| Terms and License                                                           | [link ↗](https://ai.google.dev/gemini-api/terms)                                                                           |
| More information                                                            | [link ↗](https://deepmind.google/technologies/gemini/)                                                                     |
| Request formats                                                             | Chat Completions                                                                                                           |
| Pricing                                                                     | [View pricing in the Cloudflare dashboard  ↗](https://dash.cloudflare.com/?to=/:account/ai/models/google/gemini-3.6-flash) |

## Usage

```ts
const response = await env.AI.run(
  'google/gemini-3.6-flash',
  { contents: [{ parts: [{ text: 'What are the three laws of thermodynamics?' }], role: 'user' }] },
)
console.log(response)
```

```bash
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/gemini-3.6-flash",
  "input": {
    "contents": [
      {
        "parts": [
          {
            "text": "What are the three laws of thermodynamics?"
          }
        ],
        "role": "user"
      }
    ]
  }
}'
```

Although historically there are **three main laws of thermodynamics**, a foundational law was added later and named the "Zeroth Law." Therefore, physics actually recognizes **four laws** that govern how energy, heat, and work behave. 

Here is a breakdown of all of them, starting with the classic three, followed by the foundational Zeroth Law:

---

### 1. The First Law: Conservation of Energy
> **"Energy cannot be created or destroyed; it can only change forms."**

* **What it means:** The total amount of energy in an isolated system remains constant. You can convert thermal energy (heat) into mechanical energy (work), or chemical energy into electrical energy, but you can never end up with more energy than you started with.
* **Example:** In a car engine, the chemical energy in gasoline is converted into thermal energy (heat) through burning, which is then converted into mechanical energy (moving the car) and sound energy.

---

### 2. The Second Law: The Law of Entropy
> **"The total entropy (disorder) of an isolated system always increases over time."**

* **What it means:** Natural processes move toward disorder and randomness. This law explains the "arrow of time"—why processes are irreversible. It also dictates that heat will **always flow spontaneously from hotter objects to colder ones**, never the reverse, unless external work is applied.
* **Example:** If you drop an ice cube into a hot cup of coffee, the ice melts and the coffee cools down until they reach the same temperature. You will never see a lukewarm cup of coffee spontaneously separate into boiling liquid and an ice cube.

---

### 3. The Third Law: Absolute Zero
> **"As a system approaches absolute zero, its entropy approaches a constant minimum."**

* **What it means:** Absolute zero ($0\text{ Kelvin}$, or $-273.15^\circ\text{C}$ / $-459.67^\circ\text{F}$) is the theoretical temperature where all atomic motion completely stops. The third law states that a perfect, pure crystal at absolute zero has zero entropy (perfect order). Furthermore, it is physically impossible to actually reach absolute zero in a finite number of steps.
* **Example:** As you cool matter down closer and closer to absolute zero, its atoms slow down and become extremely organized, but you can never completely strip away all kinetic energy.

---

### Bonus: The Zeroth Law (Thermal Equilibrium)
*(Formulated after the First and Second laws, but deemed so fundamental it was placed "before" them)*

> **"If two systems are each in thermal equilibrium with a third system, they are in thermal equilibrium with each other."**

* **What it means:** If Object A is the same temperature as Object B, and Object B is the same temperature as Object C, then Object A and Object C must also be the same temperature ($A = B$ and $B = C \implies A = C$). 
* **Why it matters:** This law gives us a practical definition of **temperature** and allows us to use thermometers.

---

### Summary Analogy (The "Game of Thermodynamics")
A famous, humorous way to remember these laws is:

* **Zeroth Law:** You have to play the game.
* **First Law:** You can't win; you can only break even (you can't get more energy out than you put in).
* **Second Law:** You can't even break even (because of entropy, you always lose some usable energy as waste heat).
* **Third Law:** You can't quit the game (you can never reach absolute zero).

```json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Although historically there are **three main laws of thermodynamics**, a foundational law was added later and named the \"Zeroth Law.\" Therefore, physics actually recognizes **four laws** that govern how energy, heat, and work behave. \n\nHere is a breakdown of all of them, starting with the classic three, followed by the foundational Zeroth Law:\n\n---\n\n### 1. The First Law: Conservation of Energy\n> **\"Energy cannot be created or destroyed; it can only change forms.\"**\n\n* **What it means:** The total amount of energy in an isolated system remains constant. You can convert thermal energy (heat) into mechanical energy (work), or chemical energy into electrical energy, but you can never end up with more energy than you started with.\n* **Example:** In a car engine, the chemical energy in gasoline is converted into thermal energy (heat) through burning, which is then converted into mechanical energy (moving the car) and sound energy.\n\n---\n\n### 2. The Second Law: The Law of Entropy\n> **\"The total entropy (disorder) of an isolated system always increases over time.\"**\n\n* **What it means:** Natural processes move toward disorder and randomness. This law explains the \"arrow of time\"—why processes are irreversible. It also dictates that heat will **always flow spontaneously from hotter objects to colder ones**, never the reverse, unless external work is applied.\n* **Example:** If you drop an ice cube into a hot cup of coffee, the ice melts and the coffee cools down until they reach the same temperature. You will never see a lukewarm cup of coffee spontaneously separate into boiling liquid and an ice cube.\n\n---\n\n### 3. The Third Law: Absolute Zero\n> **\"As a system approaches absolute zero, its entropy approaches a constant minimum.\"**\n\n* **What it means:** Absolute zero ($0\\text{ Kelvin}$, or $-273.15^\\circ\\text{C}$ / $-459.67^\\circ\\text{F}$) is the theoretical temperature where all atomic motion completely stops. The third law states that a perfect, pure crystal at absolute zero has zero entropy (perfect order). Furthermore, it is physically impossible to actually reach absolute zero in a finite number of steps.\n* **Example:** As you cool matter down closer and closer to absolute zero, its atoms slow down and become extremely organized, but you can never completely strip away all kinetic energy.\n\n---\n\n### Bonus: The Zeroth Law (Thermal Equilibrium)\n*(Formulated after the First and Second laws, but deemed so fundamental it was placed \"before\" them)*\n\n> **\"If two systems are each in thermal equilibrium with a third system, they are in thermal equilibrium with each other.\"**\n\n* **What it means:** If Object A is the same temperature as Object B, and Object B is the same temperature as Object C, then Object A and Object C must also be the same temperature ($A = B$ and $B = C \\implies A = C$). \n* **Why it matters:** This law gives us a practical definition of **temperature** and allows us to use thermometers.\n\n---\n\n### Summary Analogy (The \"Game of Thermodynamics\")\nA famous, humorous way to remember these laws is:\n\n* **Zeroth Law:** You have to play the game.\n* **First Law:** You can't win; you can only break even (you can't get more energy out than you put in).\n* **Second Law:** You can't even break even (because of entropy, you always lose some usable energy as waste heat).\n* **Third Law:** You can't quit the game (you can never reach absolute zero).",
            "thoughtSignature": "AY89a1/ETDBr0NG2TxxpkIfwxONbRoRzInG6WZbfIclPMB0UlgRCQ0iwDy1zt7bN/l9UhNohgkU39x70015xk3dRIC0CDbuO/HNEwpBqG8HCOYpgWj+28bGQga7K4CGLPQDI5adByEMUCBwP/SDtQX7gmZln/ZaHpgAqBREo9QNhs8mEi4EMMnXE3fQeEF/uNQKLsA9PAaQcyhGh+lEjpne5Xs472y70q0xR4LWWm2YEQiO2gCO3iROcaX7h56xmH2CYzZKInpOE9ET00rvMS/IbT3ypGSww46kgS8JN22pNTo9z3Jg9/0HmBEzVFD1C7oaU44kH3PTmHYT8gQCnKGfgLpMNlCRc0JqtmCVsU90FPp5skxYn1AuAGOjqA8Fe6uwJPG0djtQHIhtsVzK3KJ93W088D1bui4h14sc96epwc5adns4HKjYrq/xvzkKH23aOHMscDToWZi4VU4j+xq6ywG6koLCaDZSorJVYw3xFZwG5O6GRf9gsmICK/Ye6kKPtuj84j2jyJvrdPTaOMHDyo7jrKESdxDvCQL05+4VaAEnW3qqmnQ8smYXYV9tpX5avZxx0ut6x8kLiuh8Ely4XWT6YOCJoEVIpllJtDLbCFmoQ4YVu1NMs/QwTm1TMA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idatesTokenCount": 773,
    "totalTokenCount": 1863,
    "trafficType": "ON_DEMAND",
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 8
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 773
      }
    ],
    "thoughtsTokenCount": 1082
  },
  "modelVersion": "gemini-3.6-flash",
  "createTime": "2026-07-21T16:21:14.948550Z",
  "responseId": "epxfasbyOaio8sYPu5SukQY"
}
```

## Examples

**With System Instruction**  — Using a system instruction to set an agentic coding persona 

```ts
const response = await env.AI.run(
  'google/gemini-3.6-flash',
  {
    contents: [
      {
        parts: [
          { text: 'Write a Python function that merges two sorted lists into one sorted list.' },
        ],
        role: 'user',
      },
    ],
    generationConfig: { temperature: 0.2 },
    systemInstruction: {
      parts: [
        {
          text: 'You are an expert software engineering agent. Write concise, correct, well-documented code.',
        },
      ],
    },
  },
)
console.log(response)
```

```bash
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/gemini-3.6-flash",
  "input": {
    "contents": [
      {
        "parts": [
          {
            "text": "Write a Python function that merges two sorted lists into one sorted list."
          }
        ],
        "role": "user"
      }
    ],
    "generationConfig": {
      "temperature": 0.2
    },
    "systemInstruction": {
      "parts": [
        {
          "text": "You are an expert software engineering agent. Write concise, correct, well-documented code."
        }
      ]
    }
  }
}'
```

Here is the standard two-pointer implementation, which achieves optimal **$O(n + m)$** time complexity and **$O(n + m)$** space complexity.

```python
def merge_sorted_lists(list1: list, list2: list) -> list:
    """Merges two pre-sorted lists into a single sorted list.

    Args:
        list1: A sorted list of elements.
        list2: A sorted list of elements.

    Returns:
        A new sorted list containing all elements from list1 and list2.
    """
    merged = []
    i, j = 0, 0
    len1, len2 = len(list1), len(list2)

    # Compare elements from both lists and append the smaller one
    while i < len1 and j < len2:
        if list1[i] <= list2[j]:
            merged.append(list1[i])
            i += 1
        else:
            merged.append(list2[j])
            j += 1

    # Append any remaining elements from either list
    merged.extend(list1[i:])
    merged.extend(list2[j:])

    return merged


# Example Usage:
if __name__ == "__main__":
    a = [1, 3, 5, 7]
    b = [2, 4, 6, 8, 9, 10]
    result = merge_sorted_lists(a, b)
    print(result)  # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
```

### Python Standard Library Alternative
If you prefer using Python's built-in libraries, you can use `heapq.merge`, which returns an iterator and avoids loading everything into memory at once:

```python
import heapq


def merge_sorted_lists_heapq(list1: list, list2: list) -> list:
    return list(heapq.merge(list1, list2))
```

```json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Here is the standard two-pointer implementation, which achieves optimal **$O(n + m)$** time complexity and **$O(n + m)$** space complexity.\n\n```python\ndef merge_sorted_lists(list1: list, list2: list) -> list:\n    \"\"\"Merges two pre-sorted lists into a single sorted list.\n\n    Args:\n        list1: A sorted list of elements.\n        list2: A sorted list of elements.\n\n    Returns:\n        A new sorted list containing all elements from list1 and list2.\n    \"\"\"\n    merged = []\n    i, j = 0, 0\n    len1, len2 = len(list1), len(list2)\n\n    # Compare elements from both lists and append the smaller one\n    while i < len1 and j < len2:\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    merged.extend(list1[i:])\n    merged.extend(list2[j:])\n\n    return merged\n\n\n# Example Usage:\nif __name__ == \"__main__\":\n    a = [1, 3, 5, 7]\n    b = [2, 4, 6, 8, 9, 10]\n    result = merge_sorted_lists(a, b)\n    print(result)  # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n```\n\n### Python Standard Library Alternative\nIf you prefer using Python's built-in libraries, you can use `heapq.merge`, which returns an iterator and avoids loading everything into memory at once:\n\n```python\nimport heapq\n\n\ndef merge_sorted_lists_heapq(list1: list, list2: list) -> list:\n    return list(heapq.merge(list1, list2))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f6cjg6oOp30D1ku25QTq9FcBuIZ/npyzk2C8WsTPBwWQ3FWRQPHQ8nHN4/DySC4ffAgXJczhs70NZVChc92xNSuWU4BR/iSYSke0oPnX4dprIMxz87jJ1ALYvpuN0KEIkZplX+fHjrm8aSHKgfOf7aCjp3ZmhDBCJVLnXjy28xDhtvhnEylrrjJlX6KHR5B88KNr4PTep8MjRZtlGnGjhrvCPuxu4ImkMlprfyf6W+dpw5S32Rxfr/QvS2psLLKeSBZfYxqjr3eXTT7f59Djg="
          }
        ]
      },
      "finishReason": "STOP",
      "citationMetadata": {
        "citations": [
          {
            "startIndex": 640,
            "endIndex": 961,
            "uri": "https://github.com/s-m-quadri/geca-labs"
          }
        ]
      }
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 32,
    "candidatesTokenCount": 472,
    "totalTokenCount": 988,
    "trafficType": "ON_DEMAND",
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 32
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 472
      }
    ],
    "thoughtsTokenCount": 484
  },
  "modelVersion": "gemini-3.6-flash",
  "createTime": "2026-07-21T16:21:23.639338Z",
  "responseId": "g5xfauqCJ-2r8sYPq8XmoQg"
}
```

**Multi-turn Conversation**  — Continuing a multi-step coding conversation, typical of an agentic loop 

```ts
const response = await env.AI.run(
  'google/gemini-3.6-flash',
  {
    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' },
    ],
    generationConfig: { maxOutputTokens: 2048 },
  },
)
console.log(response)
```

```bash
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/gemini-3.6-flash",
  "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"
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 2048
    }
  }
}'
```

Here is how to optimize your recursive Fibonacci function using **memoization**. 

Memoization stores the results of expensive function calls in a cache (like a dictionary or map) so you don't recompute the same values over and over. This reduces the time complexity from **$O(2^n)$** (exponential) to **$O(n)$** (linear).

---

### Python Example

#### Option 1: Manual Cache (Shows how it works under the hood)
```python
def fib(n, memo={}):
    # 1. Check if the result is already in the cache
    if n in memo:
        return memo[n]

    # 2. Base cases
    if n <= 0:
        return 0
    if n == 1:
        return 1

    # 3. Compute and store in cache before returning
    memo[n] = fib(n - 1, memo) + fib(n - 2, memo)
    return memo[n]


# Test
print(fib(40))  # Returns 102334155 instantly
```

#### Option 2: Python's Built-in `@lru_cache` (Cleanest)
If you are using Python, you don't even need to modify your function logic—just add a decorator:

```python
from functools import lru_cache


# maxsize=None allows the cache to grow indefinitely
@lru_cache(maxsize=None)
def fib(n):
    if n <= 0:
        return 0
    if n == 1:
        return 1

    return fib(n - 1) + fib(n - 2)


print(fib(40))  # Instantly computes
```

---

### JavaScript Example

```javascript
function fib(n, memo = {}) {
    // 1. Check cache
    if (n in memo) return memo[n];
    
    // 2. Base cases
    if (n <= 0) return 0;
    if (n === 1) return 1;

    // 3. Compute and store
    memo[n] = fib(n - 1, memo) + fib(n - 2, memo);
    return memo[n];
}

console.log(fib(40)); // 102334155
```

---

### What changed?
* **Without Memoization ($n=40$):** Takes roughly **1.1 trillion function calls**, taking minutes or hours to finish.
* **With Memoization ($n=40$):** Takes only **40 function calls**, finishing in less than a millisecond.

*(Let me know if you need this written in a different programming language like C++, Java, or Rust!)*

```json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Here is how to optimize your recursive Fibonacci function using **memoization**. \n\nMemoization stores the results of expensive function calls in a cache (like a dictionary or map) so you don't recompute the same values over and over. This reduces the time complexity from **$O(2^n)$** (exponential) to **$O(n)$** (linear).\n\n---\n\n### Python Example\n\n#### Option 1: Manual Cache (Shows how it works under the hood)\n```python\ndef fib(n, memo={}):\n    # 1. Check if the result is already in the cache\n    if n in memo:\n        return memo[n]\n\n    # 2. Base cases\n    if n <= 0:\n        return 0\n    if n == 1:\n        return 1\n\n    # 3. Compute and store in cache before returning\n    memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n    return memo[n]\n\n\n# Test\nprint(fib(40))  # Returns 102334155 instantly\n```\n\n#### Option 2: Python's Built-in `@lru_cache` (Cleanest)\nIf you are using Python, you don't even need to modify your function logic—just add a decorator:\n\n```python\nfrom functools import lru_cache\n\n\n# maxsize=None allows the cache to grow indefinitely\n@lru_cache(maxsize=None)\ndef fib(n):\n    if n <= 0:\n        return 0\n    if n == 1:\n        return 1\n\n    return fib(n - 1) + fib(n - 2)\n\n\nprint(fib(40))  # Instantly computes\n```\n\n---\n\n### JavaScript Example\n\n```javascript\nfunction fib(n, memo = {}) {\n    // 1. Check cache\n    if (n in memo) return memo[n];\n    \n    // 2. Base cases\n    if (n <= 0) return 0;\n    if (n === 1) return 1;\n\n    // 3. Compute and store\n    memo[n] = fib(n - 1, memo) + fib(n - 2, memo);\n    return memo[n];\n}\n\nconsole.log(fib(40)); // 102334155\n```\n\n---\n\n### What changed?\n* **Without Memoization ($n=40$):** Takes roughly **1.1 trillion function calls**, taking minutes or hours to finish.\n* **With Memoization ($n=40$):** Takes only **40 function calls**, finishing in less than a millisecond.\n\n*(Let me know if you need this written in a different programming language like C++, Java, or Rust!)*",
            "thoughtSignature": "AY89a1+ctnO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WV/6nA4XdE+JfQA4CQ3JHy6vJAJPbh5cEmS/FRreFwNfS8U6wGaNx3VioqLDnVf9aI0edEEI4m0f7XWsT9dkdWxThfycC95HSFkX9jvUpv5e4dqzNo8bccenbE++4M4qhiqFL9SP5Ov6arYpl33P4rTEDGOHWHIlzupvM5EJ1IkppuSjh2UQm/PtAgHxxuE68riJ3YgbVvY5J7BekLtQMOzvLuEGFU3VGa2ArMs/dtHsfYygv3Nlrzs4IwOKuMo4V0mXYpsKxDckn/Yu3eSxgZzALRcU3Vytm+g6Mutzc5fvZCi4kDVKlW2yDrGFtTk1v116ggtQDPwREyI4+DzO7Cl8NqIZPgvM0NLnuZgNAgF4mABtf6FaTe/C8I9sHYzYVFOft3h1BN993hcAUpJW2aJHYaIChCNKUKBbX7f5nCUtgZ93NhUedLiDnOasVZB9xeR30wWglInifB77Q2Ue1QGXrBlPWyolODYjOcg4ZG42eI80sb5lAojzh3dtfGcf7AUfnNnHWV5dlSVa4uvZw1FF+RyEJuV+UcnSa3Kgjr2YPvD0GxecqBnIP7R7Weahl+mvLx362MYqfOu7+0+l02BCUcyMjWCymfBc+I5O1ILCUxQMnVf/CQZLUKziWrXwXESxeZqkAFqkzYQltrtxwjBddq"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 62,
    "candidatesTokenCount": 631,
    "totalTokenCount": 1031,
    "trafficType": "ON_DEMAND",
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 62
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 631
      }
    ],
    "thoughtsTokenCount": 338
  },
  "modelVersion": "gemini-3.6-flash",
  "createTime": "2026-07-21T16:21:27.790920Z",
  "responseId": "h5xfaoijMIWq8sYPycj20Q0"
}
```

**Spatial Reasoning**  — Higher thinking budget for a spatial reasoning task 

```ts
const response = await env.AI.run(
  'google/gemini-3.6-flash',
  {
    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: { maxOutputTokens: 4096 },
  },
)
console.log(response)
```

```bash
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "google/gemini-3.6-flash",
  "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": {
      "maxOutputTokens": 4096
    }
  }
}'
```

There are **12** smaller cubes that have exactly two red faces.

### Breakdown of the solution:

When a cube is cut into 27 equal smaller cubes, it forms a **$3 \times 3 \times 3$ grid**. The location of a small cube determines how many of its faces are painted red:

1. **Corner cubes (3 painted faces):** There are **8** corners on a cube, so 8 small cubes have 3 red faces.
2. **Edge cubes (2 painted faces):** These are the cubes along the edges, excluding the corners. A cube has **12 edges**, and with a $3 \times 3 \times 3$ grid, there is exactly 1 such cube per edge ($12 \times 1 = \mathbf{12}$).
3. **Face-center cubes (1 painted face):** There are **6** faces on a cube, and each face has 1 center cube ($6 \times 1 = 6$).
4. **Inside/Core cube (0 painted faces):** There is **1** cube hidden completely in the center.

**Total check:** $8 + 12 + 6 + 1 = 27$ cubes.

```json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "There are **12** smaller cubes that have exactly two red faces.\n\n### Breakdown of the solution:\n\nWhen a cube is cut into 27 equal smaller cubes, it forms a **$3 \\times 3 \\times 3$ grid**. The location of a small cube determines how many of its faces are painted red:\n\n1. **Corner cubes (3 painted faces):** There are **8** corners on a cube, so 8 small cubes have 3 red faces.\n2. **Edge cubes (2 painted faces):** These are the cubes along the edges, excluding the corners. A cube has **12 edges**, and with a $3 \\times 3 \\times 3$ grid, there is exactly 1 such cube per edge ($12 \\times 1 = \\mathbf{12}$).\n3. **Face-center cubes (1 painted face):** There are **6** faces on a cube, and each face has 1 center cube ($6 \\times 1 = 6$).\n4. **Inside/Core cube (0 painted faces):** There is **1** cube hidden completely in the center.\n\n**Total check:** $8 + 12 + 6 + 1 = 27$ cubes.",
            "thoughtSignature": "AY89a19pbjpH5K2G+uQep8Sf+P3G1IbQZffTYG3H42VJAG+qKUF6Kp3D7aoC5i33ePiT+Qyh6qAVi9f5n1QPEpDkGiAAqvk7cLOd8Tl8YGOIg2AAFqqBfnALSkK7bk++ViADaeJllbJTz0Mwnn0TLDDxhy7Lylqu0fNR5QMQDf6GNNka+DOufFA3PsiGt3byDrkkEA9hU2ACYq4vgaICecMAR0fR8voH8Y5qY46fZ4Ul1wvaMqLL6KEtKkQyR/TBVbAIGsRk/wwjE+11qwOgOm18MhfdcLC9UmNCQrjqVF9EaFOp1I2oL/nIj4M0bmpiDfrtYCLUYZFdoxrOECAdyR4tcds8c0FZi9KgZfVj2MoTPsYGIc1kzAkRBTIHVC5RAjPXuS5MowtUoniRaW6BVkv8FaDGi+VjSWP9cb72PHmdMY60r6b4f3kc15rji8IiiPy2DYXtxSjXwFHwIE52j4zQ7L8cUBbCeQC4VFL17h6H9ZPpa/qc6PFNqnX0zarqMl3RL9hJOu4Viqy7uxNZOleE0BtyTGGQBNKM5WZSAgF5V7kxLNivxPK5ZGkObV6KdEGyXjiUxZuTFkWhLQhTdN0I0iakTYI1Jtdkrosk4nTqCi+LkLGkFz3HGnY5ad8fJmid9YV9mECqF8LI2Sg/yXOY8diRsdCfgzlKHmtcmACyKoDP+imx4x5iPWTd+Ya4cYseWlC45H86qAGlt+ifqtzekq8YEGu9NFRTb17/OvB5FTfCYFig9+DbKbtK+sH4Kn86Inpj/hgAJ6Ql8icDfJP2dj9DXlcYZ317/A2dCi6oa2LJDLDZ4QfTbI19B133aXmD9Rag7Q2iwBtWiWMy0yfWqE7grFzCLinnQFrNEoIhgioE6PEqWIw4hcinv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TAAU34cd/DMm8BWClbE4bp3u+zi/Gl3vQgTlotQwucxPf3N9W6FBUjaYsYWti40FqFDnxV932A8SuWdu4n51lSk1xL/2suhVOzGxAiO+sN27QZV6+t5I7SBouU4i3myqOPK86RwQ6PAJIb4dU00dleexfmPOEB9kNCyFF6/JRgoF/6sAfN5S/DBe3C7zUb1F58QhXgVSrYEjUOam86SDgj1BGwgGRDL4K++TrBISun3HoOLriVKL0YfF2Mv5qgfnxDQbLdV5QbnaBY8LUiBX29XO3I4+O+Qje5F8iVy8zLMn1nI38sZ5Crsl9kZEIX+xFDMr2eP8mMghV5OLQx02j88ZUI5vwrtH95VZcomG/4+t6Jr3FYdhbiTcakp6dpccYlbeDJ9n6i+DTbhAM40J"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 31,
    "candidatesTokenCount": 265,
    "totalTokenCount": 1089,
    "trafficType": "ON_DEMAND",
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 31
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 265
      }
    ],
    "thoughtsTokenCount": 793
  },
  "modelVersion": "gemini-3.6-flash",
  "createTime": "2026-07-21T16:21:32.579668Z",
  "responseId": "jJxfatSwI9jY8sYPgtSd8Ag"
}
```

## Parameters

Schema variant

Generate ContentChat Completions

▶contents\[\]

`array`required

▶systemInstruction{}

`object`

▶generationConfig{}

`object`

▶safetySettings\[\]

`array`

▶tools\[\]

`array`

toolConfig

``

▶messages\[\]

`array`required

temperature

`number`minimum: 0maximum: 2

max\_tokens

`number`exclusiveMinimum: 0

max\_completion\_tokens

`number`exclusiveMinimum: 0

top\_p

`number`minimum: 0maximum: 1

frequency\_penalty

`number`minimum: \-2maximum: 2

presence\_penalty

`number`minimum: \-2maximum: 2

stream

`boolean`

▶stream\_options{}

`object`

▶tools\[\]

`array`

tool\_choice

``

response\_format

``

▶modalities\[\]

`array`

▶audio{}

`object`

▶candidates\[\]

`array`

▶usageMetadata{}

`object`

modelVersion

`string`

id

`string`

object

`string`

created

`number`

model

`string`

▶choices\[\]

`array`

▶usage{}

`object`

## API Schemas (Raw)

Input [ ](https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/schema-input.json "Open") [ ](https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/schema-input.json "Download") 

Output [ ](https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/schema-output.json "Open") [ ](https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/schema-output.json "Download") 

Was this helpful?

YesNo

## On this page 

[ ![](https://developers.cloudflare.com/_astro/logo.DMYpXs3t.svg) Docs ](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/#page","headline":"Gemini 3.6 Flash (Google) · Cloudflare AI docs · Cloudflare AI docs","description":"Gemini 3.6 Flash provides sustained frontier-level intelligence optimized for real-world tasks at a higher speed and lower cost, excelling at code generation, agentic execution, and spatial reasoning.","url":"https://developers.cloudflare.com/ai/models/google/gemini-3.6-flash/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
