Google shipped Gemini 3.7 Flash on August 13, 2026, three weeks after 3.6 Flash, and calls it “our most intelligent workhorse model.” For developers, the headline is straightforward: agentic coding scores increased sharply (DeepSWE v1.1 went from 49.0% to 65.3%), the introductory price is half of what 3.6 Flash launched at, and the API surface is unchanged. If you already call Gemini, swap one model ID. If you do not, this is Google’s lowest-cost entry point for a model at this capability level.
This hands-on quickstart covers getting an API key, making your first cURL request, moving it to Python and Node.js, streaming responses, tuning generationConfig, and testing requests in Apidog before adding them to application code. According to the official announcement, the model supports a 1M-token context window, 64K output tokens, multimodal input, function calling, search as a tool, and computer use.
If you built against the previous generation, the request shape carries over from the Gemini 3 Flash Preview API guide. This guide focuses on the Gemini 3.7 Flash workflow.
TL;DR
- Model ID:
gemini-3.7-flash - Synchronous endpoint:
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:generateContent
- Authenticate with
x-goog-api-key: <KEY>. - Introductory pricing is $0.75 per 1M input tokens and $3.75 per 1M output tokens through December 31, 2026. Starting January 1, 2027, prices increase to $1.50 and $7.50.
- The model accepts up to 1M input tokens and produces up to 64K output tokens.
- Inputs can include text, images, video, audio, and PDFs. Output is text.
- Benchmark changes over Gemini 3.6 Flash include:
- DeepSWE: 49.0% → 65.3%
- FrontierCode: 34.4% → 43.6%
- AutomationBench: 17.0% → 30.4%
- WebDev Arena Elo: 1538 → 1588
- Stream with
:streamGenerateContent?alt=sse. - Test the endpoint in Apidog first: store the API key in an environment, save request examples, and inspect SSE chunks live.
What Gemini 3.7 Flash is good for
Flash models generally optimize for speed and cost, and Gemini 3.7 Flash narrows the capability trade-off compared with earlier Flash releases. The benchmark gains over 3.6 Flash are substantial for a three-week release gap:
- DeepSWE v1.1: 49.0% → 65.3%
- FrontierCode 1.1 Main: 34.4% → 43.6%
- AutomationBench: 17.0% → 30.4%
- WebDev Arena Elo: 1538 → 1588
Use Gemini 3.7 Flash when:
- You run agent loops. AutomationBench nearly doubled, and Google says the model “thinks more diligently on multi-step planning and tool calls.” It is suited to short, tool-heavy agent turns.
- You generate or debug code. Google reports better debugging and stronger first-pass deployable code generation. The DeepSWE and FrontierCode gains support that use case.
- You process documents. GDP.pdf increased from 22.0% to 34.0%, and PDF is a first-class input type. The model also scored 97.0% on the 128K needle retrieval test.
-
You need budget-friendly multimodal input. Send text, images, video, audio, and PDFs through the same
contentsarray.
For more details, including the Harvey LAB-AA score and updated CBRN and cyber safeguards, see what’s new in Gemini 3.7 Flash. Gemini 3.5 Pro remains delayed, while Axios reports that Google is intentionally shipping Flash updates ahead of its next flagship model.
Get an API key
You have two primary paths.
AI Studio: fastest setup
- Open aistudio.google.com/apikey.
- Select Get API key.
- Choose a Google Cloud project.
- Copy the generated key.
The key works immediately with generativelanguage.googleapis.com. The free tier provides enough quota for prototyping, and Gemini 3.7 Flash is available in 160+ countries.
Vertex AI: production setup
Use Vertex AI if your infrastructure is already on Google Cloud.
Compared with AI Studio:
- Authentication uses OAuth through service accounts or short-lived tokens.
- Requests go to
aiplatform.googleapis.com. - You get IAM controls, audit logs, and regional endpoints.
- The model ID and request body remain the same.
Start with AI Studio for prototypes, then move to Vertex before production traffic.
Export the API key in your shell:
export GEMINI_API_KEY="AIza..."
Do not hardcode API keys or pass them through a ?key= query parameter in production. Query strings can be captured in server logs.
Endpoint and authentication
Use this endpoint for synchronous generation:
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:generateContent
For streaming, use:
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:streamGenerateContent?alt=sse
Authenticate with one header:
x-goog-api-key: $GEMINI_API_KEY
Your first request in cURL
Run this request after exporting GEMINI_API_KEY:
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"role": "user",
"parts": [{
"text": "Review this SQL for injection risk: SELECT * FROM orders WHERE id = ${orderId}"
}]
}],
"generationConfig": {
"temperature": 0.3,
"maxOutputTokens": 1024
}
}'
The response includes:
-
candidates: generated candidates -
candidates[].content.parts: generated text or function calls -
candidates[].finishReason: why generation stopped -
usageMetadata: input and output token counts
Monitor usageMetadata, especially for long outputs. At the introductory rate, output tokens cost five times more than input tokens.
If you are migrating from OpenAI-style APIs, note the schema difference:
- Gemini uses
contents,role, andparts. - OpenAI-style APIs commonly use
messages.
Python quickstart
Install or upgrade the official SDK:
pip install --upgrade google-generativeai
Create a model with a system instruction and generation settings:
import os
import google.generativeai as genai
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
model = genai.GenerativeModel(
model_name="gemini-3.7-flash",
system_instruction=(
"You are a code reviewer. "
"Flag issues as blocking or non-blocking."
),
generation_config={
"temperature": 0.3,
"max_output_tokens": 2048,
},
)
response = model.generate_content(
"Review this Flask route for security issues:\n\n"
"@app.route('/user/<id>')\n"
"def get_user(id):\n"
" return db.execute(f'SELECT * FROM users WHERE id = {id}')"
)
print(response.text)
print("input tokens:", response.usage_metadata.prompt_token_count)
print("output tokens:", response.usage_metadata.candidates_token_count)
Send a PDF
Multimodal inputs use the same content structure. Upload a PDF through the Files API, then provide the file alongside your instruction:
invoice = genai.upload_file("q3-invoice.pdf")
response = model.generate_content([
invoice,
"Extract the invoice number, total, and due date as JSON.",
])
print(response.text)
This maps directly to the document extraction workload reflected in the GDP.pdf benchmark increase from 22.0% to 34.0%.
Node.js quickstart
Install the Node.js SDK:
npm install @google/generative-ai
Use responseMimeType and responseSchema when downstream code needs structured JSON:
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
const model = genAI.getGenerativeModel({
model: "gemini-3.7-flash",
generationConfig: {
temperature: 0.3,
maxOutputTokens: 2048,
responseMimeType: "application/json",
responseSchema: {
type: "object",
properties: {
severity: {
type: "string",
enum: ["blocking", "non-blocking"],
},
issues: {
type: "array",
items: { type: "string" },
},
},
required: ["severity", "issues"],
},
},
});
const result = await model.generateContent(
"Review this Express handler: " +
"app.get('/search', (req, res) => res.send(eval(req.query.q)))"
);
console.log(JSON.parse(result.response.text()));
responseSchema makes the output parseable by constraining the candidate shape. Pair it with:
responseMimeType: "application/json"
Without the JSON MIME type, the schema is ignored.
Streaming
For chat interfaces and user-facing flows, stream the response.
In Python, set stream=True:
stream = model.generate_content(
"Explain the N+1 query problem with a concrete ORM example.",
stream=True,
)
for chunk in stream:
if chunk.text:
print(chunk.text, end="", flush=True)
With raw HTTP:
- Call
:streamGenerateContent?alt=sse. - Parse server-sent events.
- Read each
data:line as a partialcandidatespayload. - Wait for the final chunk before recording token usage.
The final SSE event includes usageMetadata, so token accounting is only complete after the stream closes.
Tune generationConfig
These are the parameters you will use most often:
| Parameter | Type | What it does |
|---|---|---|
maxOutputTokens |
integer | Caps output length, up to the model’s 64K limit. This is your main cost control. |
temperature |
number | Ranges from 0 to 2. Use 0.2–0.4 for code and extraction; use 0.7+ for creative text. |
responseMimeType |
string | Set to application/json for JSON output. |
responseSchema |
object | Enforces an output structure when paired with the JSON MIME type. |
topP |
number | Nucleus sampling cutoff. Keep the default unless you are tuning intentionally. |
stopSequences |
array | Stops generation when a listed string appears. Useful for delimiter-based parsing. |
Start with a conservative configuration for structured tasks:
{
"generationConfig": {
"temperature": 0.3,
"maxOutputTokens": 1024,
"responseMimeType": "application/json"
}
}
Output tokens cost $3.75 per million during the introductory period and $7.50 per million starting in January 2027. Set maxOutputTokens to the amount your application actually needs rather than defaulting to the 64K maximum.
For worked cost examples, see the Gemini 3.7 Flash pricing breakdown.
Beyond generationConfig, requests can include:
-
toolsfor function declarations, search as a tool, and computer use -
toolConfigfor controlling or forcing tool calls
For the tool-calling response loop, parallel calls, and declaration examples, see the Gemini 3.7 Flash function calling tutorial.
Test the endpoint in Apidog before writing app code
Prompt iteration inside a script is slow: edit, rerun, inspect output, and spend tokens every time. A faster workflow is to validate the request shape in an API client, save working examples, then move the known-good request into application code.
Use Apidog to set up the workflow:
- Create a project and import the Generative Language API OpenAPI spec from Google’s API docs.
-
Create an environment variable named
GEMINI_API_KEY. -
Set
x-goog-api-keyat the environment level so requests inherit it without embedding the key in saved request bodies. -
Create a model variable with the value
gemini-3.7-flash. -
Use the visual JSON editor to build the
contentsarray and validate nestedparts. - Call the streaming endpoint to inspect SSE chunks and response latency.
- Save successful responses as examples so later tests can use fixtures instead of live API calls.
Store the model ID as a variable so you can compare models without editing multiple URLs:
GEMINI_MODEL=gemini-3.7-flash
To test Gemini 3.6 Flash, update only the environment value:
GEMINI_MODEL=gemini-3.6-flash
After saving requests, create test scenarios that assert:
finishReason- response schema validity
- expected fields in
candidates -
usageMetadatatoken counts
This turns manual prompt checks into regression tests. For a related QA workflow, see the API testing guide for QA engineers.
Error handling and rate limits
Gemini errors return a top-level error object with code, status, and message.
| Code | Status | Meaning | Fix |
|---|---|---|---|
| 400 | INVALID_ARGUMENT |
Malformed body, invalid role, or empty contents. |
Validate the request body in Apidog before sending. |
| 401 | UNAUTHENTICATED |
Missing or revoked API key. | Re-export GEMINI_API_KEY and verify that the key is active in AI Studio. |
| 403 | PERMISSION_DENIED |
Project access or billing issue. | Check project settings and billing status. |
| 429 | RESOURCE_EXHAUSTED |
Rate limit or daily quota reached. | Use backoff with jitter, batch work, or upgrade tiers. |
| 500 | INTERNAL |
Transient server fault. | Retry with exponential backoff. |
| 503 | UNAVAILABLE |
Service overload. | Retry after a few seconds; on Vertex, try another region. |
Use these production practices:
- Retry 429 and 5xx errors. Add jittered exponential backoff around every call.
- Log request and response metadata. Capture status codes, latency, model ID, and token usage without logging sensitive prompts or credentials.
- Do not hardcode rate-limit values. Limits vary by tier and can change. Check the live Gemini API pricing and limits page and alert when usage reaches 80% of quota.
-
Put model IDs behind environment variables. If a prompt regresses, switching from
gemini-3.7-flashback togemini-3.6-flashbecomes a configuration change instead of a deployment.
A minimal retry wrapper in Python:
import random
import time
RETRYABLE_STATUS_CODES = {429, 500, 503}
def call_with_retry(fn, max_attempts=5):
for attempt in range(max_attempts):
try:
return fn()
except Exception as error:
if attempt == max_attempts - 1:
raise
delay = min(2 ** attempt, 16) + random.uniform(0, 0.5)
time.sleep(delay)
FAQ
Is Gemini 3.7 Flash free to use?
AI Studio includes a free tier with daily quota suitable for prototyping. The paid introductory rate is $0.75 per 1M input tokens through December 31, 2026. For tier details, see the guide to free Gemini API access.
What is the difference between AI Studio and Vertex AI?
The model and request body are the same. The integration details differ:
-
AI Studio: API key authentication with
generativelanguage.googleapis.com -
Vertex AI: OAuth authentication with
aiplatform.googleapis.com, plus IAM, audit logs, and regional endpoints
Start with AI Studio, then move to Vertex as production requirements grow.
Can I send images, audio, and PDFs to Gemini 3.7 Flash?
Yes. Inputs can include text, images, video, audio, and PDFs. Send them as parts inside the contents array, either inline as base64 data or by Files API reference. Output is text only.
How large are the context window and output limit?
Gemini 3.7 Flash supports 1M input tokens and up to 64K output tokens. The 97.0% score on the 128K needle retrieval test suggests strong long-context recall, but chunking unnecessary input still reduces cost.
Should I upgrade from Gemini 3.6 Flash?
For agentic and coding workloads, the benchmark gap makes upgrading a reasonable default. The API change is typically a one-line model ID update:
- gemini-3.6-flash
+ gemini-3.7-flash
Regression-test prompts before routing production traffic. For migration considerations, see the 3.6 to 3.7 Flash migration guide.
Where Gemini 3.7 Flash fits in your stack
Gemini 3.7 Flash is a notable release because the introductory price decreased while benchmark performance increased. Through the end of 2026, it costs half of Gemini 3.6 Flash’s launch rate while scoring 16 points higher on DeepSWE and nearly doubling its AutomationBench result.
A practical default is:
- Route agent loops, code tasks, and document extraction to
gemini-3.7-flash. - Use
maxOutputTokensto control output costs. - Keep the model ID in an environment variable.
- Retain a rollback path to
gemini-3.6-flash. - Validate synchronous, streaming, and tool-calling requests before application integration.
Start with the cURL request, confirm the response shape, and then move the request into an API client before writing production code. Download Apidog to import the Gemini spec, bind your key once, and test synchronous, streaming, and tool-calling requests from one workspace.

Top comments (0)