快訊
  • Agents
  • Gemini

Gemini API 的 Managed Agents 可以接自己的 sandbox 了

Google AI Studio 在 2026-11-11(美國時間)宣布,Gemini API 的 managed agents 可以「bring your own sandbox」,改用自架的環境。原本 agent 的工具都跑在 Google 代管的 Linux sandbox,現在可以放到自己控制的機器上。

怎麼接

官方文件寫的三個步驟:

  1. 呼叫 POST /v1beta/environments,帶 {"mode": "self_hosted"},拿到環境 id 和一組只給一次的 environment_key。
  2. 在自己的 sandbox 裡,用那組 key 跑 gemini-api environments connect(開源的 google-gemini/gemini-api-cli)。
  3. 呼叫 interactions.create 時,把環境 id 放進 environment。

sandbox 是用對外 HTTPS 連到 Google,不需要開任何對內的防火牆 port。

要注意的地方

  • 代管 sandbox 才有的選項(sources、network、env、/files 快照)不能用在自架環境,帶了會回 400 INVALID_ARGUMENT。
  • runtime 也能跑在 Docker 或 rootless Podman 裡;測試時可以直接在本機跑,但本機模式下 execute_bash 會直接在主機上執行,除非加 --disable-bash。
  • 文件列了幾個 sandbox 供應商的接法範例,例如 Google Cloud Run、Cloudflare Sandbox、Daytona、E2B、Fly.io、Modal、Vercel Sandbox。
  • environments 和 managed agents 都還在 preview,功能和 schema 可能會改。

Gemini API Managed Agents can now run tools in your own sandbox

On 2026-11-11 (US time), Google AI Studio announced that Gemini API managed agents can now “bring your own sandbox” with self-hosted environments. Agent tools used to run only in Google-hosted Linux sandboxes; now they can run on infrastructure you control.

How to connect

The docs list three steps:

  1. Call POST /v1beta/environments with {"mode": "self_hosted"} to get an environment id and a one-time environment_key.
  2. Inside your sandbox, run gemini-api environments connect (from the open-source google-gemini/gemini-api-cli) with that key.
  3. Pass the environment id in environment when calling interactions.create.

The sandbox connects to Google over outbound HTTPS and needs no inbound firewall ports.

Things to know

  • Hosted-sandbox options (sources, network, env, and /files snapshots) don’t apply to self-hosted environments, which reject them with 400 INVALID_ARGUMENT.
  • The runtime can also run in Docker or rootless Podman. For testing it can run locally, but local mode runs execute_bash directly on the host unless you pass --disable-bash.
  • The docs include example setups for sandbox providers such as Google Cloud Run, Cloudflare Sandbox, Daytona, E2B, Fly.io, Modal, and Vercel Sandbox.
  • Environments and managed agents are in preview, and features and schemas may change.

來源