DEV Community

Cover image for How to use the Gemini 3.6 Flash API ?
Hassann
Hassann

Posted on • Originally published at apidog.com

How to use the Gemini 3.6 Flash API ?

You call Gemini 3.6 Flash with the model ID gemini-3.6-flash over Google’s Gemini API. Google shipped the Flash refresh on July 21, 2026, and 3.6 Flash is the workhorse tier: lower output cost than 3.5 Flash, a 1M-token context window, and text, image, video, audio, and PDF inputs. This guide walks through getting a key, making curl and Python requests, choosing key parameters, and adding a regression test.

Try Apidog today

Gemini 3.6 Flash API overview

What you need before you start

You need three things:

  • A Google account to create an API key.
  • A Gemini API key from Google AI Studio.
  • An HTTP client:
    • curl for terminal-based requests
    • Python for application code
    • An API client such as Apidog for saved requests and tests

You can start without billing. The AI Studio free tier is rate-limited, but it is sufficient for learning and prototyping.

Get a Gemini API key

  1. Open Google AI Studio and sign in.
  2. Click Get API key.
  3. Select Create API key.
  4. Copy the generated key and store it securely.

Create a Gemini API key in Google AI Studio

Treat this key as a password. Do not put it in browser-side code or commit it to Git.

Export it as an environment variable instead:

export GEMINI_API_KEY="your_key_here"
Enter fullscreen mode Exit fullscreen mode

The official Python SDK reads GEMINI_API_KEY automatically, so you do not need to hard-code a secret in source files. See the Gemini API documentation for the canonical setup instructions.

Make your first API call

Send a POST request to the model’s generateContent endpoint.

Call Gemini 3.6 Flash with curl

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.6-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {"text": "Explain how APIs work"}
        ]
      }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

The request body uses this structure:

  • contents: conversation messages
  • parts: content within each message
  • text: a text input part

This structure also supports multimodal requests later, where you can send text alongside images, audio, video, or PDFs.

A successful response returns generated text under:

candidates[0].content.parts[0].text
Enter fullscreen mode Exit fullscreen mode

Check that field in your application and in automated tests.

Call Gemini 3.6 Flash with Python

Install the SDK:

pip install google-genai
Enter fullscreen mode Exit fullscreen mode

Then create a request:

from google import genai

client = genai.Client()  # Reads GEMINI_API_KEY from the environment

response = client.models.generate_content(
    model="gemini-3.6-flash",
    contents="Explain how APIs work",
)

print(response.text)
Enter fullscreen mode Exit fullscreen mode

Because the client reads GEMINI_API_KEY from the environment, the key stays out of your application code.

Configure the parameters that matter

The default request works, but these settings are useful when you move beyond a one-off prompt.

Add a system instruction

Use a system instruction for rules that should apply across the request or conversation, such as output formatting or response style.

Examples:

  • “Answer in JSON only.”
  • “You are a terse code reviewer.”
  • “Return a numbered migration plan.”

Keep these instructions separate from user-provided content instead of repeating them in every prompt.

Set a maximum output length

Use a maximum output token limit to control response size, latency, and cost.

Gemini 3.6 Flash can generate up to 64k output tokens. Raise the limit for long-form output and lower it for concise API responses.

Send multimodal input

Gemini 3.6 Flash accepts:

  • Text
  • Images
  • Video
  • Audio
  • PDFs

Add additional content as entries in the parts array. The model returns text output, so the request pattern is many input formats in and text out.

The model supports up to a 1M-token input context window, which can accommodate large documents or long transcripts.

Tune reasoning effort

Gemini 3.6 Flash reasons before answering on difficult prompts. This improves multi-step tasks, but reasoning tokens are billed as output tokens.

When available, tune reasoning effort to trade response depth for speed and cost.

Use the Gemini API documentation as the source of truth for current field names and supported configuration options.

Pricing and the free tier

Gemini 3.6 Flash costs:

Token type Price
Input $1.50 per 1M tokens
Output $7.50 per 1M tokens

The output price is lower than the $9.00 per 1M output tokens charged by 3.5 Flash. Gemini 3.6 Flash also tends to generate around 17% fewer output tokens for the same task.

One important billing detail: output pricing includes thinking tokens. A reasoning-heavy prompt can cost more than the visible answer length suggests.

For a detailed breakdown, see the Gemini 3.6 Flash pricing guide.

The AI Studio free tier is rate-limited by requests per minute and per day. It is useful for development and tests, but it is not intended for production-scale traffic. Google may use free-tier data to improve its products.

Read how to use Gemini 3.6 Flash for free for more details. When you need higher limits, enable billing; your existing integration can continue using the same key.

Test and debug the Gemini API in Apidog

A curl command proves that a request works once. A saved API test helps detect broken headers, expired keys, response schema changes, and deployment regressions.

Use Apidog to create a repeatable test for your Gemini request.

1. Create a POST request

Create a request with:

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.6-flash:generateContent
Enter fullscreen mode Exit fullscreen mode

Set the body to:

{
  "contents": [
    {
      "parts": [
        {
          "text": "Explain how APIs work"
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

2. Store the API key as an environment variable

Create an Apidog environment variable named:

GEMINI_API_KEY
Enter fullscreen mode Exit fullscreen mode

Then set the request header:

x-goog-api-key: {{GEMINI_API_KEY}}
Enter fullscreen mode Exit fullscreen mode

This keeps secrets out of shared request definitions and lets you use different keys for development, staging, and production.

3. Add response assertions

Add assertions for:

  • HTTP status is 200
  • candidates[0].content.parts[0].text exists
  • The generated text is not empty

These checks confirm that the request did more than return a generic HTTP response: the model actually generated usable output.

4. Save and schedule the test

Save the request in a collection, then schedule it as a regression test.

Run it on a schedule or in CI so you catch failures before they reach users.

Download Apidog to build and run this test. Apidog does not run the model; it helps verify that the API integration your application depends on continues to behave as expected.

Common errors and fixes

401 Unauthorized: invalid key

Your key is wrong, revoked, missing, or unresolved.

Check the following:

  • The x-goog-api-key header contains the key from AI Studio.
  • Your shell environment variable is exported.
  • Your API client resolved {{GEMINI_API_KEY}}.
  • There are no trailing spaces in the key.

429 Too Many Requests: rate limit

You exceeded a per-minute or per-day limit, which is common on the free tier.

To fix it:

  • Reduce request frequency.
  • Add retries with backoff.
  • Avoid tight test loops.
  • Enable billing when you need higher limits.

404 Not Found: model not found

Usually, the model ID is misspelled.

Use this exact ID:

gemini-3.6-flash
Enter fullscreen mode Exit fullscreen mode

Do not use:

gemini-3.5-flash
gemini-flash-3.6
Enter fullscreen mode Exit fullscreen mode

The Lite model in the same release is gemini-3.5-flash-lite, which is a different model on the 3.5 line.

FAQ

What is the exact model ID for Gemini 3.6 Flash?

Use:

gemini-3.6-flash
Enter fullscreen mode Exit fullscreen mode

Use it in the SDK model argument and in the REST path before :generateContent.

Is the Gemini 3.6 Flash API free?

There is a rate-limited free tier through AI Studio. It is suitable for learning and prototyping. Production traffic requires billing. See how to use it for free.

What can I send to the model?

You can send text, images, video, audio, and PDFs. The context window supports up to 1M input tokens. Output is text only.

Why is my bill higher than the visible response length?

The $7.50 per 1M output token price includes thinking tokens. Reasoning-heavy requests can use more billable output tokens than the visible response shows.

Is this the same API as Gemini 3.5 Flash?

The request shape is the same. If you previously used the Gemini 3.5 API, update the model ID to gemini-3.6-flash.

Gemini 3.6 Flash has a lower output price and tends to use fewer output tokens for the same work.

Can I use one key in curl, Python, and Apidog?

Yes. One AI Studio key works in all three. Store it as an environment variable in each tool rather than hard-coding it.

Where to go from here

You now have a key, a working curl request, a Python implementation, and a regression-testing workflow.

Start on the free tier, keep secrets in environment variables, and use the official Gemini API docs for advanced configuration. Once the integration becomes production-critical, add an Apidog test to catch silent API changes before your users do.

Top comments (0)