Gemini 3 Flash
Text Generation • Google
google/gemini-3-flash
- Third-party
- Zero data retention
Gemini 3 Flash is Google's fast multimodal model with frontier intelligence, superior search, and grounding capabilities.
| Model Info | |
|---|---|
| Context Window ↗ | 1,000,000 tokens |
| Terms and License | link ↗ |
| More information | link ↗ |
| Zero data retention | Yes |
| Request formats | Chat Completions |
| Pricing | <ul><li>Input <=200k (per 1M)$0.50</li><li>Cached input <=200k (per 1M)$0.05</li><li>Output <=200k (per 1M)$3.00</li><li>Input >200k (per 1M)$0.50</li><li>Cached input >200k (per 1M)$0.05</li><li>Output >200k (per 1M)$3.00</li></ul> |
Usage
const response = await env.AI.run(
'google/gemini-3-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-flash",
"input": {
"contents": [
{
"parts": [
{
"text": "What are the three laws of thermodynamics?"
}
],
"role": "user"
}
]
}
}'
While there are technically four laws (starting with the "Zeroth Law"), the **Three Laws of Thermodynamics** are the fundamental principles that describe how energy, heat, and matter behave.
Here is a breakdown of the three laws:
---
### 1. The First Law: Conservation of Energy
**Definition:** Energy cannot be created or destroyed, only transformed from one form to another. The total energy of an isolated system remains constant.
* **In simple terms:** You can't get something for nothing.
* **The Equation:** $\Delta U = Q - W$
* ($\Delta U$ is the change in internal energy, $Q$ is heat added, and $W$ is work done by the system).
* **Example:** In a car engine, the chemical energy of the gasoline is converted into heat and then into mechanical work to move the car.
### 2. The Second Law: Entropy
**Definition:** The total entropy (disorder) of an isolated system can never decrease over time; it can only remain constant or increase. This law dictates the "arrow of time."
* **In simple terms:** Things tend to get messy and disorganized over time. Heat always flows spontaneously from a hotter object to a colder object, never the other way around without adding work.
* **Key Concept:** This law explains why 100% efficiency is impossible—some energy is always "lost" as waste heat.
* **Example:** If you place a hot cup of coffee in a cold room, the coffee cools down as heat spreads into the room. The heat will never spontaneously jump back from the room into the coffee to make it boil again.
### 3. The Third Law: Absolute Zero
**Definition:** As the temperature of a system approaches absolute zero ($0$ Kelvin or $-273.15^\circ$ Celsius), the entropy of a perfect crystal approaches a constant minimum (usually zero).
* **In simple terms:** You can’t reach absolute zero.
* **Key Concept:** As atoms get colder, they slow down. At absolute zero, all molecular motion would essentially stop. However, because moving heat requires a temperature difference, it is physically impossible to reach a temperature of exactly zero Kelvin in a finite number of steps.
* **Example:** Scientists use advanced lasers and magnets to get atoms within billionths of a degree of absolute zero, but they can never quite hit the "stop" button entirely.
---
### Summary Mnemonic
There is a famous (and slightly cynical) way to remember these laws, often called **"Ginsberg’s Theorem"**:
1. **First Law:** You can't win. (You can't get more energy out than you put in).
2. **Second Law:** You can't break even. (You always lose some energy to entropy).
3. **Third Law:** You can't get out of the game. (You can't reach absolute zero to stop the process).
***
**Note on the Zeroth Law:** If you ever hear about a "Zeroth Law," it simply states that if two systems are each in thermal equilibrium with a third system, they are in thermal equilibrium with each other. This is the law that allows us to use thermometers.
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "While there are technically four laws (starting with the \"Zeroth Law\"), the **Three Laws of Thermodynamics** are the fundamental principles that describe how energy, heat, and matter behave.\n\nHere is a breakdown of the three laws:\n\n---\n\n### 1. The First Law: Conservation of Energy\n**Definition:** Energy cannot be created or destroyed, only transformed from one form to another. The total energy of an isolated system remains constant.\n\n* **In simple terms:** You can't get something for nothing.\n* **The Equation:** $\\Delta U = Q - W$\n * ($\\Delta U$ is the change in internal energy, $Q$ is heat added, and $W$ is work done by the system).\n* **Example:** In a car engine, the chemical energy of the gasoline is converted into heat and then into mechanical work to move the car.\n\n### 2. The Second Law: Entropy\n**Definition:** The total entropy (disorder) of an isolated system can never decrease over time; it can only remain constant or increase. This law dictates the \"arrow of time.\"\n\n* **In simple terms:** Things tend to get messy and disorganized over time. Heat always flows spontaneously from a hotter object to a colder object, never the other way around without adding work.\n* **Key Concept:** This law explains why 100% efficiency is impossible—some energy is always \"lost\" as waste heat.\n* **Example:** If you place a hot cup of coffee in a cold room, the coffee cools down as heat spreads into the room. The heat will never spontaneously jump back from the room into the coffee to make it boil again.\n\n### 3. The Third Law: Absolute Zero\n**Definition:** As the temperature of a system approaches absolute zero ($0$ Kelvin or $-273.15^\\circ$ Celsius), the entropy of a perfect crystal approaches a constant minimum (usually zero).\n\n* **In simple terms:** You can’t reach absolute zero.\n* **Key Concept:** As atoms get colder, they slow down. At absolute zero, all molecular motion would essentially stop. However, because moving heat requires a temperature difference, it is physically impossible to reach a temperature of exactly zero Kelvin in a finite number of steps.\n* **Example:** Scientists use advanced lasers and magnets to get atoms within billionths of a degree of absolute zero, but they can never quite hit the \"stop\" button entirely.\n\n---\n\n### Summary Mnemonic\nThere is a famous (and slightly cynical) way to remember these laws, often called **\"Ginsberg’s Theorem\"**:\n\n1. **First Law:** You can't win. (You can't get more energy out than you put in).\n2. **Second Law:** You can't break even. (You always lose some energy to entropy).\n3. **Third Law:** You can't get out of the game. (You can't reach absolute zero to stop the process).\n\n***\n\n**Note on the Zeroth Law:** If you ever hear about a \"Zeroth Law,\" it simply states that if two systems are each in thermal equilibrium with a third system, they are in thermal equilibrium with each other. This is the law that allows us to use thermometers.",
"thoughtSignature": "AY89a1+RdEkQqSCfe6KTvKWMknfIBywa5lOKfzJSDw4DHkMrF7/+jEpXKC9RABDVwVPQKy7Q9lCrPUvMBcuV858jRzDwHe88wDTSzoCgfjF7ztathjHzYzjkUyPg61Eg46vOVPb2f5Ca/bCUkdl4tvbk04gv/GueV57KO0wJbnF2oBjX/estVrz2k9mQCX/oSEEQDUIYg4BwjzqAlK7vQaIePTbsapXiEBugPRd2/rfscLbiEnwvx66ZmpCsxRpnzWIuw8biuQBTmqU5tzA8eJ7wez0w1O6KX+kcrnA9wEAqT0MF+S2qhF3Sc28320v9a6JoFbSdzUL7MccJ75M1ruo25NgnBFzckrPC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ChI75Vonk8kGZRK7c79+CbP3Hm+FYe2R53k+uPGOJgRiCYNjRzuS66R7u3NvzNnz/F1FKPTW/cosrusLx3ghPcfvhawu7O9xUDhP6uyUgN3n62gluc7TXHbRRiUQFF33A7noDGZC8X1M2BpvYivm/IMeFlBDsJDiGQgVNK5fYCWz+rjfxC7Q6eFFcrs9TEwvKnsrTtxjuAIVC5eng6sH/bjYpexZ0egORleQOQ+MpGqVx7lhK9ILLtXNkbhIpyvc7RgDyckCt8ei9HvG5kp1HZ6GNn3AE+MoCpVO+0HTNCV8f3SKuXI+SEHR1/2DyXq1h8MDCYLrrEDiyhylPsZ5wOQqrNRtxQQ8hBTG8TB8/dK9WbPn9d9uzEMxJ0FuCVW+phxy30wfrfPgK1VF+h44LG4ouCDXXn3ulIBpdVPGo2oZJFOuLtcJSreXyHklkQX9nVT6HmUtRafT82+78DWAm5chkZ933SJsSabovTAj2uVuMXgDD30Gpk7oJ6wuSKw8vjbPk/0i6Ep8L21Mv++Kuj3WskXQlEtXgujOiQx/CdpTmlTbjeQ6hv0/bagQVuEN1RtNRAS6lmyCqcuo2VuaUqwDvGjRT6+/OM/7memyezkWmJAufx7vgvV+BmlIMUCcNQKRFT"
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 8,
"candidatesTokenCount": 697,
"totalTokenCount": 1107,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 8
}
],
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 697
}
],
"thoughtsTokenCount": 402
},
"modelVersion": "gemini-3-flash-preview",
"createTime": "2026-07-24T21:49:35.132185Z",
"responseId": "791jatmICOSg3dAPo6eioAg",
"gatewayMetadata": {
"keySource": "Unified"
}
}
Examples
<details>
<summary>With System Instruction — Using a system instruction to set context</summary>
const response = await env.AI.run(
'google/gemini-3-flash',
{
contents: [{ parts: [{ text: 'How do I read a JSON file in Python?' }], role: 'user' }],
generationConfig: { temperature: 0.3 },
systemInstruction: {
parts: [{ text: 'You are a helpful coding assistant specializing in Python.' }],
},
},
)
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-flash",
"input": {
"contents": [
{
"parts": [
{
"text": "How do I read a JSON file in Python?"
}
],
"role": "user"
}
],
"generationConfig": {
"temperature": 0.3
},
"systemInstruction": {
"parts": [
{
"text": "You are a helpful coding assistant specializing in Python."
}
]
}
}
}'
```
To read a JSON file in Python, you use the built-injson` module.
Here is the most common and recommended way to do it:
The Standard Method
```python import json
