Repository Public
1[See all models](https://ai.google.dev/gemini-api/docs/models)23Gemini 3.8 Flash (`gemini-3.8-flash`) is generally available (GA) and ready for production use. It is our most intelligent Flash model, engineered for long-horizon software engineering, autonomous agents, and complex enterprise workflows.45This guide explains what's new in Gemini 3.8 Flash, API changes, code examples, and migration guidance.67## New model89| Model | Model ID | Default thinking level | Pricing | Description |10|---|---|---|---|---|11| Gemini 3.8 Flash | `gemini-3.8-flash` | `medium` | 3.8 Flash is available through the end of year at an introductory price of $0.75/1M input tokens and $3.75/1M output tokens; see [pricing](https://ai.google.dev/gemini-api/docs/pricing) for more details. | Our most intelligent Flash model, engineered for long-horizon software engineering, autonomous agents, and complex enterprise workflows. |1213Gemini 3.8 Flash supports a 1M token context window, 64k max output tokens, tunable thinking levels (`low`, `medium`, `high`), and the same comprehensive suite of built-in tools.1415For complete specs, see the [Gemini 3.8 Flash model page](https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash). For introductory pricing details, see the [pricing section](https://ai.google.dev/gemini-api/docs/latest-model#pricing) below or the [pricing page](https://ai.google.dev/gemini-api/docs/pricing#gemini-3.8-flash).1617## Quickstart1819### Python2021 from google import genai2223 client = genai.Client()2425 interaction = client.interactions.create(26 model="gemini-3.8-flash",27 input="Write a three.js script that renders a realistic 3D black hole."28 )2930 print(interaction.output_text)3132### JavaScript3334 import { GoogleGenAI } from "@google/genai";3536 const client = new GoogleGenAI({});3738 const interaction = await client.interactions.create({39 model: "gemini-3.8-flash",40 input: "Write a three.js script that renders a realistic 3D black hole.",41 });4243 console.log(interaction.output_text);4445### Java4647 import com.google.genai.Client;48 import com.google.genai.gaos.models.interactions.CreateModelInteraction;49 import com.google.genai.gaos.models.interactions.Interaction;50 import com.google.genai.gaos.models.interactions.InteractionsInput;51 import com.google.genai.gaos.models.interactions.Model;52 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;5354 Client client = new Client();5556 CreateModelInteraction params =57 CreateModelInteraction.builder()58 .model(Model.of("gemini-3.8-flash"))59 .input(60 InteractionsInput.of(61 "Write a three.js script that renders a realistic 3D black hole."))62 .build();6364 Interaction interaction =65 client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();6667 System.out.println(interaction.outputText().orElse(""));6869### REST7071 curl "https://generativelanguage.googleapis.com/v1beta/interactions" \72 -H "x-goog-api-key: $GEMINI_API_KEY" \73 -H 'Content-Type: application/json' \74 -X POST \75 -d '{76 "model": "gemini-3.8-flash",77 "input": "Write a three.js script that renders a realistic 3D black hole."78 }'7980## What's new in Gemini 3.8 Flash8182- **Long-horizon software engineering:** Delivers strong results on real-world coding benchmarks, complex multi-file refactoring, and deterministic tool execution. See the [evaluation methodology](https://deepmind.google/models/evals-methodology/gemini-3-8-flash/) for details.83- **Autonomous agents:** Lets you build resilient multi-step planning and tool orchestration workflows, substantially reducing failed loops and errors.84- **Complex enterprise workflows:** Delivers superior accuracy, deep reasoning, and high factual rigor across demanding domain tasks and large-scale data pipelines.85- **Default model for Managed Agents:** The default agent for managed agents: the [Antigravity agent](https://ai.google.dev/gemini-api/docs/antigravity-agent), now uses Gemini 3.8 Flash. The [Antigravity SDK](https://antigravity.google/docs/sdk/overview/) also uses Gemini 3.8 Flash by default.86- **Introductory pricing:** Gemini 3.8 Flash is available at an introductory rate of $0.75/1M input tokens and $3.75/1M output tokens through December 31, 2026. Standard pricing of $1.50/1M input tokens and $7.50/1M output tokens takes effect January 1, 2027.8788Gemini 3.8 Flash can use more tokens on longer running and complex tasks, by design. To deliver higher-quality results on difficult, multi-step goals, the model takes smaller reasoning steps, calls tools iteratively, and verifies its work along the way. Not every workflow needs this level of verification. For everyday tasks, you can lower the [reasoning](https://ai.google.dev/gemini-api/docs/latest-model#understanding-reasoning-levels) effort to reduce token consumption. Alternatively, Gemini 3.7 Flash remains fully supported.8990## Understanding reasoning levels9192Gemini 3.8 Flash gives you flexible control over latency and intelligence by adjusting the model's thinking level:9394- **Low thinking effort**: Reduces time-to-answer for latency-critical tasks like incident response pipelines, real-time chat, writing drafts, and fast data analysis.95- **Medium (default):** Best quality for most tasks. Recommended for complex code and agentic use cases, providing higher first-pass accuracy.96- **High thinking effort**: Maximizes the model's reasoning and tool orchestration capabilities. Best for deep reasoning, mathematics, and difficult multi-step tasks.9798> [!NOTE]99> **Note:** `minimal` thinking level is not supported for Gemini 3.8 Flash and will return an error.100101The following example sets `thinking_level` to `medium` for a complex code analysis request:102103### Python104105 from google import genai106107 client = genai.Client()108109 interaction = client.interactions.create(110 model="gemini-3.8-flash",111 input="Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",112 generation_config={113 "thinking_level": "medium" # Balanced reasoning effort for complex tasks114 }115 )116117 print(interaction.output_text)118119### JavaScript120121 import { GoogleGenAI } from "@google/genai";122123 const client = new GoogleGenAI({});124125 const interaction = await client.interactions.create({126 model: "gemini-3.8-flash",127 input: "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",128 generation_config: {129 thinking_level: "medium"130 }131 });132133 console.log(interaction.output_text);134135### Java136137 import com.google.genai.Client;138 import com.google.genai.gaos.models.interactions.CreateModelInteraction;139 import com.google.genai.gaos.models.interactions.GenerationConfig;140 import com.google.genai.gaos.models.interactions.Interaction;141 import com.google.genai.gaos.models.interactions.InteractionsInput;142 import com.google.genai.gaos.models.interactions.Model;143 import com.google.genai.gaos.models.interactions.ThinkingLevel;144 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;145146 Client client = new Client();147148 CreateModelInteraction params =149 CreateModelInteraction.builder()150 .model(Model.of("gemini-3.8-flash"))151 .input(152 InteractionsInput.of(153 "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely."))154 .generationConfig(155 GenerationConfig.builder()156 .thinkingLevel(ThinkingLevel.MEDIUM) // Balanced reasoning effort for complex tasks157 .build())158 .build();159160 Interaction interaction =161 client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();162163 System.out.println(interaction.outputText().orElse(""));164165### REST166167 curl "https://generativelanguage.googleapis.com/v1beta/interactions" \168 -H "x-goog-api-key: $GEMINI_API_KEY" \169 -H 'Content-Type: application/json' \170 -X POST \171 -d '{172 "model": "gemini-3.8-flash",173 "input": "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",174 "generation_config": {175 "thinking_level": "medium"176 }177 }'178179## Updated Antigravity agent180181Due to its improved performance and reasoning, the [Antigravity agent](https://ai.google.dev/gemini-api/docs/antigravity-agent) in Gemini Managed Agents is now built with Gemini 3.8 Flash by default.182183### Python184185 from google import genai186187 client = genai.Client()188189 interaction = client.interactions.create(190 agent="antigravity-preview-09-2026",191 input=(192 "Audit https://web.dev for performance, Core Web Vitals, and SEO. "193 "Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. "194 "Check search indexing with Google Search for site:web.dev. "195 "Format the output as a side-by-side scorecard table with prioritized fixes."196 ),197 environment="remote",198 )199200 print(interaction.output_text)201202### JavaScript203204 import { GoogleGenAI } from "@google/genai";205206 const client = new GoogleGenAI({});207208 const interaction = await client.interactions.create({209 agent: "antigravity-preview-09-2026",210 input: "Audit https://web.dev for performance, Core Web Vitals, and SEO. Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. Check search indexing with Google Search for site:web.dev. Format the output as a side-by-side scorecard table with prioritized fixes.",211 environment: "remote",212 }, { timeout: 300000 });213214 console.log(interaction.output_text);215216### Java217218 import com.google.genai.Client;219 import com.google.genai.gaos.models.interactions.AgentOption;220 import com.google.genai.gaos.models.interactions.CreateAgentInteraction;221 import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;222 import com.google.genai.gaos.models.interactions.Interaction;223 import com.google.genai.gaos.models.interactions.InteractionsInput;224 import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;225226 Client client = new Client();227228 CreateAgentInteraction params =229 CreateAgentInteraction.builder()230 .agent(AgentOption.of("antigravity-preview-09-2026"))231 .input(232 InteractionsInput.of(233 "Audit https://web.dev for performance, Core Web Vitals, and SEO. "234 + "Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. "235 + "Check search indexing with Google Search for site:web.dev. "236 + "Format the output as a side-by-side scorecard table with prioritized fixes."))237 .environment(CreateAgentInteractionEnvironment.of("remote"))238 .build();239240 Interaction interaction =241 client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();242243 System.out.println(interaction.outputText().orElse(""));244245### REST246247 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \248 -H "Content-Type: application/json" \249 -H "x-goog-api-key: $GEMINI_API_KEY" \250 -d '{251 "agent": "antigravity-preview-09-2026",252 "input": "Audit https://web.dev for performance, Core Web Vitals, and SEO. Query Google'\''s PageSpeed Insights API for both Mobile and Desktop strategies. Check search indexing with Google Search for site:web.dev. Format the output as a side-by-side scorecard table with prioritized fixes.",253 "environment": "remote"254 }'255256The underlying Gemini model [can be configured](https://ai.google.dev/gemini-api/docs/antigravity-agent#model-selection) using `agent_config`.257258## Migration checklist259260> [!NOTE]261> **Note:** **Automate this migration with a coding agent.** If you use a coding agent that supports skills (like Antigravity), install the [gemini-api-dev skill](https://ai.google.dev/gemini-api/docs/coding-agents#gemini-api-dev) and run:262263 `/gemini-api-dev migrate my app to Gemini 3.8 Flash`264265### Migrate to gemini-3.8-flash266267- **Update Model ID:** Change your target model string to `gemini-3.8-flash`.268- **Remove deprecated sampling parameters:**269 - Strip `temperature`, `top_p`, and `top_k` from generation configs.270 - Replace `thinking_budget` with the string enum `thinking_level`. Note that `minimal` is not supported on 3.8 Flash.271 - Remove `candidate_count` (unsupported in Gemini 3 and later).272- **Enforce turn validation rules:**273 - Standardize multi-turn conversations on server-side `previous_interaction_id`.274 - Remove prefilled model turns.275- **Audit function calling:**276 - Place multimodal assets inside the response payload.277 - Format inline instructions using `\n\n`.278 - If you see `Malformed_Function_Call` errors tied to pre-tool text, see [Workarounds for pre-tool text requirements](https://ai.google.dev/gemini-api/docs/function-calling#workarounds-for-pre-tool-text-requirements).279 - Only if using generateContent API: Ensure all `FunctionResponse` objects include `call_id` and `name`.280- **Baseline Gemini 3 requirements:** For SDK updates and thought signature preservation, see the [Gemini 3.5 Migration Checklist](https://ai.google.dev/gemini-api/docs/whats-new-gemini-3.5#migration).281282## Pricing283284Take advantage of introductory pricing across Google AI Studio and Gemini Enterprise Agent Platform through December 31, 2026 for Gemini 3.8 Flash, Gemini 3.7 Flash, and Gemini 3.6 Flash. Standard pricing takes effect January 1, 2027. For complete pricing tiers, see the [pricing page](https://ai.google.dev/gemini-api/docs/pricing#gemini-3.8-flash).285286## Next steps287288- Review API specs on the [Models Overview](https://ai.google.dev/gemini-api/docs/models).289- Explore multi-agent orchestration in the [Interactions API Overview](https://ai.google.dev/gemini-api/docs/interactions-overview).290- Test and refine prompts in [Google AI Studio](https://aistudio.google.com/prompts/new_chat?model=gemini-3.8-flash).