AD
All DayTools
View All Developer ToolsHTML/CSS MinifierJSON FormatterRegex TesterBase64 Encoder/DecoderUUID GeneratorMarkdown to HTMLColor PickerQR Code GeneratorSSL CheckerHash GeneratorTimestamp Converter
View All Fitness ToolsBMI CalculatorBMR CalculatorCalorie CalculatorMacro CalculatorBody Fat Calculator
View All Finance ToolsEMI CalculatorSavings CalculatorCurrency ConverterMortgage CalculatorGST CalculatorTip CalculatorROI CalculatorInterest CalculatorIBAN Validator
View All Social Media ToolsYouTube EarningsFacebook EarningsInstagram EngagementTikTok EarningsSocial ROI Calculator
View All SEO ToolsSEO ScoreKeyword DensityMeta Tag GeneratorSitemap GeneratorRobots.txt GeneratorBacklink CheckerPage Speed Analyzer
Email GeneratorAds Copy Generator

Web Tools

Malware ScannerWebsite Safety CheckerIs This Site SafeScan URL for VirusDNS CheckerSpeed CheckerSecurity AuditWebsite EvaluationWebsite ScreenshotIP LookupHTTP Header CheckerPort CheckerURL Status Checker

Text Tools

Word CounterCase ConverterURL EncoderNotepadLorem Ipsum GeneratorText Diff Checker

Excel Tools

Excel Formula GeneratorCSV to ExcelDuplicate RemoverRandom Data GeneratorRow CounterText to ColumnsPercentage CalculatorDate CalculatorConditional FormattingChart Generator

File Tools

Image CompressorWebP to JPEGWebP to PNGBackground RemoverSVG to PNGSVG to JPGSVG to CodeCrop ImageSocial Media ResizePDF MergePDF CompressorPDF/Image ConverterInvoice GeneratorExcel/PDF ConverterWord/PDF Converter

Utilities

Password GeneratorAge CalculatorUnit ConverterTip Calculator
Blog
AD
All Day ToolsFree Online Tools

Your one-stop destination for free online tools. Convert PDFs, calculate finances, optimize images, and boost your productivity - all without signing up or paying a dime.

70+ Free Tools
100% Free Forever

Why Choose Us?

  • No registration required
  • Your files stay private
  • Lightning fast results

PDF Tools

  • PDF Compressor
  • PDF to Image
  • Image to PDF
  • PDF Merge
  • Word to PDF

Finance Tools

  • Currency Converter
  • EMI Calculator
  • Interest Calculator
  • GST Calculator
  • ROI Calculator
  • Invoice Generator

Fitness & Health

  • BMI Calculator
  • BMR Calculator
  • Calorie Calculator
  • Macro Calculator
  • Body Fat Calculator

Excel Tools

  • Excel Formula Generator
  • CSV to Excel
  • Duplicate Remover
  • Chart Generator
  • Excel/PDF Converter

Social Media

  • YouTube Earnings
  • Instagram Engagement
  • TikTok Earnings
  • Facebook Earnings
  • Social ROI Calculator

SEO Tools

  • SEO Score Checker
  • Meta Tag Generator
  • Keyword Density
  • Sitemap Generator
  • Page Speed Analyzer

Web Tools

  • DNS Checker
  • Speed Checker
  • Security Audit
  • Website Screenshot
  • SSL Checker

Developer Tools

  • JSON Formatter
  • HTML/CSS Minifier
  • Regex Tester
  • Color Picker
  • QR Code Generator

© 2026 All Day Tools. All rights reserved.

Featured on PostYourStartup
Privacy Policy
← Back to blog

AI How-To · 9 min read

How to Build a Managed AI Agent with Gemini API: Step-by-Step

Google’s managed-agent workflow lets developers run an AI agent in a remote Linux sandbox, give it instructions and skills, and let it use supported tools for multi-step tasks—without building all of the runtime infrastructure themselves.

Published October 29, 2026 · All Day Tools Team

Abstract AI agent working inside a glowing cloud sandbox connected to code, documents, browser tools, and data

Many AI demos stop after generating text. An AI agent can take a more structured route: interpret a task, use approved tools, execute code, manage files, and return a result. Google’s Gemini API managed agents package an agent harness and a remote environment into an API workflow. The environment can provide code execution, web search, URL context, and a workspace that can be continued across interactions.

This guide walks through a small, controlled first project. Product names, preview identifiers, SDK behavior, and access rules can change, so check the linked official documentation before using the example in production.

What are Gemini managed agents?

Managed agents use Google’s Antigravity agent harness through the Gemini API Interactions API. A request can provision a remote Linux sandbox, run the agent loop, and return its output and interaction identifiers. Developers can add a system instruction, provide files such as AGENTS.md or SKILL.md, and configure which tools the agent may use.

It is useful for developers prototyping report generation, data analysis, file transformation, research workflows, or coding tasks that require several steps. It is not a reason to give a model unrestricted access to production accounts or sensitive systems.

Before you start

  • A Google account and access to the Gemini API or Google AI Studio.
  • A Gemini API key stored in an environment variable—not hard-coded in source code or a public repository.
  • Python 3 and the current Google Gen AI SDK, or the equivalent JavaScript SDK.
  • A small, non-sensitive task that is safe to run in an isolated environment.

Managed agents and the documented Antigravity agent identifier are preview-era features. Confirm current availability, regional support, billing, quotas, data handling, and terms for your account before relying on them.

Step 1: Create an API key and set it securely

Open Google AI Studio’s API key page and create or select a key if your account is eligible. Set it in your shell environment so the SDK can read it. For example, on macOS or Linux:

export GEMINI_API_KEY="YOUR_API_KEY_HERE"

Use a secret manager or your deployment platform’s secret settings for long-running services. Do not commit the key to Git, paste it into a prompt, or include it in logs.

Step 2: Install the Google Gen AI SDK

python -m pip install --upgrade google-genai

Run this in a virtual environment for the project. If installation or imports fail, consult the SDK’s current official quickstart rather than pinning an old version from an unrelated tutorial.

Step 3: Make your first managed-agent call

Start with a harmless task that creates and reads a small text file. The example below follows the current managed-agent quickstart pattern and requests a fresh remote environment.

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-09-2026",
    input=(
        "Write a Python script that creates a file named "
        "summary.txt containing three tips for organizing "
        "a small project. Then read the file and summarize it."
    ),
    environment="remote",
)

print("Interaction ID:", interaction.id)
print("Environment ID:", interaction.environment_id)
print("Result:", interaction.output_text)

The interaction ID identifies the run; the environment ID identifies the remote workspace. Save these identifiers if you intend to continue work in the same environment. The exact SDK fields and preview agent ID may change as the API evolves.

Step 4: Shape the agent’s behavior with clear instructions

Use a system instruction to define the agent’s role, output format, and boundaries. For example:

system_instruction = (
    "You are a careful project assistant. Inspect inputs before "
    "changing files. Do not delete files, send messages, spend "
    "money, or access credentials. State uncertainty and report "
    "which files you created or changed."
)

Pass this value as the system_instruction parameter to client.interactions.create. Instructions improve consistency, but they are not a security boundary. Enforce important restrictions outside the model too, including tool allowlists, filesystem permissions, and human approval for consequential actions.

Step 5: Add repeatable skills and project context

For recurring work, mount a concise .agents/AGENTS.md file with general operating rules and a task-specific .agents/skills/your-skill/SKILL.md with steps, quality checks, and expected outputs. Google’s documentation shows how inline sources can be supplied in the environment when you create an interaction. Keep the instructions short, testable, and version-controlled.

Only provide data the agent needs. Treat external documents and web pages as untrusted input: they may contain prompt-injection attempts that ask the agent to ignore its instructions or reveal secrets.

Step 6: Review the result instead of trusting it blindly

  1. Check the returned output for correctness and completeness.
  2. Inspect generated files before using or distributing them.
  3. Test the same task with incomplete, misleading, and malformed input.
  4. Record the interaction ID, relevant logs, model identifier, and outcome for debugging.
  5. Use a human approval step before any external communication, production deployment, account change, or destructive operation.

Common limitations and safety considerations

  • Preview changes: Agent identifiers, tool support, limits, and SDK parameters may change. Verify the current docs before deploying.
  • Sandbox is not a blanket guarantee: Keep secrets out of the task, restrict tools and inputs, and validate file outputs. Do not assume a remote environment removes every risk.
  • Costs and quotas: Tool execution and model usage can incur charges and limits. Set budget alerts and timeouts where available.
  • Untrusted content: Search results, files, and web pages can contain malicious instructions. Keep permissions narrow and treat retrieved content as data, not policy.
  • Reliability: Agents can misunderstand tasks, make faulty edits, or stop partway through. Build retry logic, checkpoints, validation, and rollback into real workflows.

Example use cases to try first

  • Turn a small CSV sample into a summary table and written findings.
  • Generate a draft report from non-confidential public data.
  • Rename and categorize a set of sample files in a sandbox.
  • Write and run unit tests for a toy code project, then explain failures.

Keep the first task narrow enough that you can manually verify the output in minutes. Expand only after you understand the failure modes.

Frequently asked questions

Do I need to build my own agent runtime?

Not for the managed-agent quickstart. The service provisions the documented remote environment and runs the agent loop. You still need to design instructions, permissions, validation, and your application’s error handling.

Can a managed agent use my private data?

Only provide data through supported mechanisms and only after reviewing the service’s current data-handling terms and your organization’s requirements. Do not send sensitive information to a prototype by default.

Can I use this directly in production?

Do not treat a tutorial as a production architecture. Confirm service availability and terms, test with representative workloads, isolate credentials, apply least privilege, monitor activity, and require approval for consequential actions.

Official documentation

  • Gemini API: Managed agents quickstart
  • Gemini API: Building managed agents and adding instructions or skills
  • Google’s announcement: Introducing Managed Agents in the Gemini API
  • Gemini API key guidance

Takeaway

Gemini managed agents can reduce the infrastructure needed for a multi-step AI workflow, but they do not remove the need for engineering discipline. Start with a small remote-sandbox task, add clear instructions, limit access, inspect outputs, and expand only after the workflow is reliable and safe.