Gemini 3.7 Flash

Text Generation • Google

google/gemini-3.7-flash

  • Third-party

Gemini 3.7 Flash is a highly capable, natively multimodal reasoning model optimized for agentic workflows and real-world tasks.

Model Info
Context Window ↗ 1,048,576 tokens
Terms and License link ↗
More information link ↗
Request formats Chat Completions
Pricing <ul><li>Input (per 1M tokens)$0.75</li><li>Output (per 1M tokens)$3.75</li><li>Cached input (per 1M tokens)$0.075</li></ul>

Usage

const response = await env.AI.run(
  'google/gemini-3.7-flash',
  { contents: [{ parts: [{ text: 'What are the three laws of thermodynamics?' }], role: 'user' }] },
)
console.log(response)
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.7-flash",
  "input": {
    "contents": [
      {
        "parts": [
          {
            "text": "What are the three laws of thermodynamics?"
          }
        ],
        "role": "user"
      }
    ]
  }
}'
The **laws of thermodynamics** define fundamental physical quantities (like temperature, energy, and entropy) and describe how they behave under various circumstances. 

While there are historically **three** main laws, scientists later added a foundational law called the **Zeroth Law**. Here are all four, clearly explained:

---

### **1. The First Law (Law of 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 (like the universe) remains constant. When heat is added to a system, it either increases the system's internal energy or does work on the surroundings.
* **Equation:** $\Delta U = Q - W$ 
  *(Change in internal energy = Heat added to the system $-$ Work done by the system)*
* **Everyday Example:** A car engine converts the *chemical energy* stored in gasoline into *thermal energy* (heat) and *mechanical energy* (motion). No new energy is created.

---

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

* **What it means:** Natural processes are irreversible. Heat will spontaneously flow from hotter objects to colder objects, but never the reverse on its own. **Entropy** is a measure of disorder or unusable energy; because some energy is always lost as heat in any transfer, the universe becomes increasingly disordered.
* **Consequence:** It is impossible to build a machine that is 100% efficient (a perpetual motion machine).
* **Everyday Example:** If you drop an ice cube into a cup of hot coffee, the heat moves from the coffee to the ice, melting it. You will never see a cup of warm coffee spontaneously separate into boiling coffee and an ice cube.

---

### **3. The Third Law (Absolute Zero)**
> **"The entropy of a pure crystalline substance approaches zero as the temperature approaches absolute zero."**

* **What it means:** **Absolute zero** (0 Kelvin, or $-273.15^\circ\text{C} / -459.67^\circ\text{F}$) is the point where all atomic motion stops. At this temperature, a perfect crystal would have zero disorder (zero entropy). 
* **Consequence:** It is physically impossible to cool any object down to absolute zero in a finite number of steps, though scientists can get within billionths of a degree close.

---

### *Bonus: The Zeroth Law (Thermal Equilibrium)*
*(Formulated after the first two, but deemed so fundamental it was placed before them.)*

> **"If System A is in thermal equilibrium with System B, and System B is in thermal equilibrium with System C, then System A is also in thermal equilibrium with System C."**

* **What it means:** "Thermal equilibrium" simply means no heat flows between two objects because they are the same temperature. This law defines the concept of **temperature** and allows us to use **thermometers**.

---

### **A Common Memory Trick (Ginsberg’s Analogy)**
A humorous way physicists summarize the laws of thermodynamics:
1. **First Law:** You can't win; you can only break even (energy is conserved).
2. **Second Law:** You can't break even (entropy always increases, so energy is lost as unusable heat).
3. **Third Law:** You can't get out of the game (you can never reach absolute zero).
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "The **laws of thermodynamics** define fundamental physical quantities (like temperature, energy, and entropy) and describe how they behave under various circumstances. \n\nWhile there are historically **three** main laws, scientists later added a foundational law called the **Zeroth Law**. Here are all four, clearly explained:\n\n---\n\n### **1. The First Law (Law of 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 (like the universe) remains constant. When heat is added to a system, it either increases the system's internal energy or does work on the surroundings.\n* **Equation:** $\\Delta U = Q - W$ \n  *(Change in internal energy = Heat added to the system $-$ Work done by the system)*\n* **Everyday Example:** A car engine converts the *chemical energy* stored in gasoline into *thermal energy* (heat) and *mechanical energy* (motion). No new energy is created.\n\n---\n\n### **2. The Second Law (Law of Entropy)**\n> **\"The entropy of an isolated system always increases over time.\"**\n\n* **What it means:** Natural processes are irreversible. Heat will spontaneously flow from hotter objects to colder objects, but never the reverse on its own. **Entropy** is a measure of disorder or unusable energy; because some energy is always lost as heat in any transfer, the universe becomes increasingly disordered.\n* **Consequence:** It is impossible to build a machine that is 100% efficient (a perpetual motion machine).\n* **Everyday Example:** If you drop an ice cube into a cup of hot coffee, the heat moves from the coffee to the ice, melting it. You will never see a cup of warm coffee spontaneously separate into boiling coffee and an ice cube.\n\n---\n\n### **3. The Third Law (Absolute Zero)**\n> **\"The entropy of a pure crystalline substance approaches zero as the temperature approaches absolute zero.\"**\n\n* **What it means:** **Absolute zero** (0 Kelvin, or $-273.15^\\circ\\text{C} / -459.67^\\circ\\text{F}$) is the point where all atomic motion stops. At this temperature, a perfect crystal would have zero disorder (zero entropy). \n* **Consequence:** It is physically impossible to cool any object down to absolute zero in a finite number of steps, though scientists can get within billionths of a degree close.\n\n---\n\n### *Bonus: The Zeroth Law (Thermal Equilibrium)*\n*(Formulated after the first two, but deemed so fundamental it was placed before them.)*\n\n> **\"If System A is in thermal equilibrium with System B, and System B is in thermal equilibrium with System C, then System A is also in thermal equilibrium with System C.\"**\n\n* **What it means:** \"Thermal equilibrium\" simply means no heat flows between two objects because they are the same temperature. This law defines the concept of **temperature** and allows us to use **thermometers**.\n\n---\n\n### **A Common Memory Trick (Ginsberg’s Analogy)**\nA humorous way physicists summarize the laws of thermodynamics:\n1. **First Law:** You can't win; you can only break even (energy is conserved).\n2. **Second Law:** You can't break even (entropy always increases, so energy is lost as unusable heat).\n3. **Third Law:** You can't get out of the game (you can never reach absolute zero).",
            "thoughtSignature": "AY89a19XdC4x/f+U8hCl13sukl2kjv7cr4AAfyhSwG6PrM0gqQI0UzuL58Cyc42V2aoktYrBm9y3PV9o8xeqfFmrMsWLhF+VRtKFVTFy0R1uAZksXMeolxKfpKEa1DQS+j7gJUzvuZ9NtB54RqMgqHalOz8fg9kq5X/PvmlBO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mu3on0ONd087rTyjl+TXjW/dGZEL5MqWh8F8TeCvb+NsRFnKou+malXbUHjTtft8Du/M/0XcmH+7rM0VeUTvEiu9Xr5xzuichY0zO7w6eYBbcPrNVKBCxzamwBKCPNoaK3bQTzFhecucJDbPZuUvmp9qYZss8iPvyCNiA36xV49tvnycbKTI8KVTeTccYxqouN5js/fZvHbzQfoj5C7eWtlZlQqgrTGxNxcJ6eRuAwdQ1sytW9BTAahQjEZlSN5yOSTlg9iRoAx8LWyI="
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 8,
    "candidatesTokenCount": 752,
    "totalTokenCount": 1433,
    "trafficType": "ON_DEMAND",
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 8
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 752
      }
    ],
    "thoughtsTokenCount": 673
  },
  "modelVersion": "gemini-3.7-flash",
  "createTime": "2026-08-13T18:07:02.084997Z",
  "responseId": "xgd-aoWYBeumrb8Pht-PuQw"
}

Examples

<details>

<summary>With System Instruction — Using a system instruction to set an agentic coding persona</summary>

const response = await env.AI.run(
  'google/gemini-3.7-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)
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.7-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 a clean, efficient Python function using the two-pointer approach, running in $O(n + m)$ time and space complexity:

```python from typing import TypeVar

T = TypeVar("T")

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

Args:
    list1: A sorted list of elements.
    list2: Another sorted list of elements (same comparable type).

Returns:
    A new sorted list containing all elements from both lists.

Complexity:
    Time: O(n + m) where n and m are lengths of list1 and list2.
    Space: O(n + m) for the resulting merged list.
"""
merged: list[T] = []
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
merged.extend(list1[i:])
merged.extend(list2[j:])

return merged