
How-Tos
How to call Gemini 3.8 Flash and the Antigravity preview agent
Google’s Gemini API docs show how to call Gemini 3.8 Flash and the Antigravity preview agent through the Interactions API.
Searcher → Analyst → Writer → Editor · subagentic-20261010-0800
The Gemini API docs use two different Interactions API calls. A model request names gemini-3.8-flash. An Antigravity request names the preview agent in the sample below and sets the environment to remote. The latest-model page marks the Interactions API as recommended. This is the current call path, not a launch note. That page describes Gemini 3.8 Flash as generally available and ready for production use. It was last updated 2026-10-09 UTC.
Specs and price
gemini-3.8-flash is the model ID. The page calls it the most intelligent Flash model, engineered for long-horizon software engineering, autonomous agents, and complex enterprise workflows.
It supports a 1 million token context window, 64k max output tokens, and thinking levels low, medium, and high. Medium is the default. It keeps the same comprehensive suite of built-in tools.
Introductory pricing is $0.75 per million input tokens and $3.75 per million output tokens through December 31, 2026. Standard pricing of $1.50 per million input tokens and $7.50 per million output tokens takes effect January 1, 2027. That introductory window applies across Google AI Studio and Gemini Enterprise Agent Platform, and it also covers Gemini 3.6 Flash, which remains supported.
On longer, complex tasks the model can use more tokens by design. It takes smaller reasoning steps, calls tools iteratively, and verifies its work. For everyday tasks, lower the reasoning effort.
Call the model
The Python quickstart creates a client with no arguments, then creates an interaction with the model string. The last line prints the interaction output text. These pages do not show how that client loads a key, so do not add a constructor argument the sample does not have. JavaScript, Java, Go, and REST blocks on the same page make the same request. Copy those blocks whole, including the credential header in the REST samples. Do not retype header values from memory.
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
input="Write a three.js script that renders a realistic 3D black hole."
)
print(interaction.output_text)
Set thinking_level
thinking_level is a string inside the generation config object in the sample, not a sibling of the model field. Medium is already the default. The page still sets it on a code-analysis prompt. If you are migrating, replace thinking_budget with thinking_level. minimal is not supported. Choose low, medium, or high.
low is for latency-critical tasks such as incident response, real-time chat, drafts, and fast data analysis. medium is the recommendation for complex code and agentic use cases. high is for deep reasoning, mathematics, and difficult multi-step work.
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
input="Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
generation_config={
"thinking_level": "medium" # Balanced reasoning effort for complex tasks
}
)
print(interaction.output_text)
Java, Go, JavaScript, and REST samples on the page set the same level. Copy those lines. Do not invent SDK type names from the Python field.
Call the preview agent
Do not send a model field on this call. The Antigravity page describes a general-purpose managed agent: one Interactions API call that reasons, executes code, manages files, and browses the web inside your own secure Linux sandbox, hosted by Google. It is built with Gemini 3.8 Flash and uses the same harness as the Antigravity IDE. The latest-model page says this agent is the default for managed agents, and that the Antigravity SDK uses Gemini 3.8 Flash by default.
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input="Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
environment="remote",
)
print(interaction.output_text)
JavaScript samples on both pages pass a timeout as a second argument. Copy that argument from the page. The Python samples do not show a timeout. REST samples post an agent field and an environment field instead of a model field. Copy that curl whole rather than editing the model sample.
Both pages say the underlying Gemini model can be configured with agent_config. These samples do not include that object. Copy it from the model selection section on the Antigravity agent page. Do not guess keys.
What remote adds
Each call can provision a Linux sandbox and start a tool-use loop. The agent plans, acts, observes results, and repeats until the task is done.
- Code execution runs Bash, Python, and Node.js, including package installs, tests, and builds. The tool type is
code_execution. - File tools read, write, edit, search, and list files. Files persist across interactions. They turn on when you set
environment. - Web access is Google Search and URL fetching, tool types
google_searchandurl_context. - Context compaction triggers at about 135k tokens so long multi-turn sessions can continue without losing context or hitting token limits.
By default the agent has those three tools. Pass tools only when restricting that set or adding custom functions. A sample keeps search and URL context, each as an object with a type field, and still sets the environment to remote.
Custom function calls are a second turn. The weather sample on the Antigravity page shows the follow-up: the same agent, previous_interaction_id, and the prior interaction's environment id. Copy that sample rather than rebuilding the result object. Filesystem calls may look like function calls, but the environment runs those itself. The page also says synchronous hooks can intercept code execution and filesystem work inside the remote sandbox. Hook fields are not in the call samples.
Multimodal input is text and image only. Images are inline base64. Copy the image object from the page, including its mime type, instead of rebuilding it.
Later sections on that page cover MCP servers, customization, background execution, triggers, pricing, and limitations. The call samples do not list agent-specific prices.
Migration checklist
From the latest-model page, if an app still targets an older Flash model:
- Change the model string to
gemini-3.8-flash. - Replace
thinking_budgetwiththinking_level. Do not sendminimal. - Remove
temperature,top_p, andtop_k. Removecandidate_count, which the checklist says is unsupported in Gemini 3 and later. Remove prefilled model turns. - Standardize multi-turn conversations on server-side
previous_interaction_id. - Place multimodal assets inside the response payload, and format inline instructions with the blank line the checklist writes as two newline escapes.
Malformed_Function_Callerrors tied to pre-tool text are covered in a workaround section the checklist points to, not copied here. Only on the generateContent API: everyFunctionResponsemust includecall_idandname. - Thought-signature preservation is listed as a baseline Gemini 3 requirement. The checklist points to another page for it. It is not specified here.
Try this next
Run the model quickstart, then run the Antigravity sample with the remote environment on a task that needs files or the web, so you see the sandbox loop instead of a single completion. Before you override the default model, open the model selection section on the Antigravity agent page and copy agent_config from there.