gemini-agents-api: Managing Stateful Gemini Enterprise Agents with REST

Introduction

Running custom Agents on the Gemini Enterprise Agent Platform often involves more than just calling a conversation interface once. You need to define system instructions in advance, mount skill directories from GCS or the Skill Registry, declare tools such as code execution, filesystem, search, or MCP, and be able to query and modify configurations after going live. If these steps are merely recorded in internal documentation, it is difficult for Agents and Coding Agents to automatically assemble the correct REST requests and JSON payloads according to the same contract.

The gemini-agents-api introduced below is an official Skill released by Google in the google/skills repository (metadata version 1.0.0, category AiAndMachineLearning). It targets the Managed Agents API—the Control Plane for the platform’s Agent resources—used to programmatically create, configure, list, update, or delete server-hosted stateful Agent resources before initiating conversations (Data Plane).

What is this

gemini-agents-api (Full name: Gemini Enterprise Agent Platform - Managed Agents API Skill) is an set of operating instructions installable onto an Agent: it includes authentication methods, REST endpoints, request body structures, and the polling method for Long-Running Operations (LRO) during Agent creation.

Unlike Skills that only cover inference or conversation (e.g., the Gemini Interactions API Skill in the same repository), this Skill focuses on the resource lifecycle: pre-configuring customizable, stateful Agent containers for developers, supporting system instructions, sandbox files, custom Skill registries, and configuration descriptions for local or remote tools.

Official Path: skills/cloud/gemini-agents-api.

Core Functions

Based on the Skill body and frontmatter, the verified capabilities include:

  1. Authentication & Environment: All control plane requests use Application Default Credentials (ADC) derived Bearer Tokens and point to the production global endpoint (LOCATION must be set to a region supported by the Managed Agents API, e.g., global).
  2. Create Agent (LRO): POST to the agents collection; can specify base_agent, description, system_instruction, tools, and mount directories from Google Cloud Storage to the container workspace (e.g., /.agent/skills) via base_environment, or mount revisions from the Skill Registry.
  3. Tools & MCP: The tools in the creation request can declare built-in platform types (e.g., code_execution, filesystem, google_search, url_context) and also configure third-party MCP servers (type: mcp, containing url and optional headers); the documentation requires explaining that the platform will securely route tool requests to the specified MCP URL, and custom headers are sent only to that URL.
  4. Poll Creation Result: Creation returns an operation name; poll GET https://aiplatform.googleapis.com/v1beta1/{OPERATION_NAME} until done: true, and read the ready Agent resource from response.
  5. Read Agent: GET a single Agent, returning the full configuration (tools, environment, etc.).
  6. Scope Note: The Skill description also covers listing, updating, and deleting Agents; after installing this Skill, the Agent will reference the corresponding endpoints and payloads according to the full SKILL body in the repository (the examples below focus on Create, Poll, and Get as given in the materials).

Installation & Enablement

The official Google repository distributes via skills.sh, and the installation method is an interactive selection of the Skill and target Agent:

npx skills add google/skills

Follow the prompts to select gemini-agents-api (or install all Cloud / AI related Skills), and specify the Agent to configure and the installation scope (project or global). The environment must have npx (usually provided with Node.js). To update installed Skills:

npx skills update

The materials do not list separate steps for Cursor, Codex CLI, and Claude Code; all three follow the same npx skills add flow, depending on how your current Coding Agent mounts Skills.

Typical Usage

1. Prepare Project Variables and Access Token

Control plane requests require PROJECT_ID, LOCATION, and ACCESS_TOKEN:

export PROJECT_ID="your-project-id"
export LOCATION="global"
export ACCESS_TOKEN=$(gcloud auth print-access-token)

LOCATION must be a value supported by the Managed Agents API in the current region (the documentation example is global or other available regional endpoints).

2. Control Plane Base URL

The Agent resource collection endpoint is:

https://aiplatform.googleapis.com/v1beta1/projects/{PROJECT_ID}/locations/{LOCATION}/agents

3. Create Agent and Mount GCS Skill Directory

Below uses curl to initiate creation; the platform will asynchronously spin up the container, and the response is an LRO object rather than an immediately available Agent:

curl -X POST "https://aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/agents" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{
    "id": "my-custom-agent",
    "base_agent": "antigravity-preview-05-2026",
    "description": "A professional agent configured with remote tools and mounted Cloud Storage directories.",
    "system_instruction": "You are a helpful, domain-expert assistant.",
    "tools": [
      {"type": "code_execution"},
      {"type": "filesystem"},
      {"type": "google_search"},
      {"type": "url_context"}
    ],
    "base_environment": {
      "type": "remote",
      "sources": [
        {
          "type": "gcs",
          "source": "gs://your-agent-bucket-name/skills",
          "target": "/.agent/skills"
        }
      ],
      "network": {
        "allowlist": [
          { "domain": "*" }
        ]
      }
    }
  }'

To mount from the Skill Registry instead of GCS, change an item in sources to type: skill_registry, where source is a resource path like projects/your-project-id/locations/global/skills/my-math-skill/revisions/123456789012, and target remains a path inside the container (e.g., /.agent/skills).

4. Poll LRO until Agent is Ready

Extract the operation path from the name field of the creation response, e.g., projects/1234567890/locations/global/operations/operation-987654321-abcde:

curl -X GET "https://aiplatform.googleapis.com/v1beta1/projects/1234567890/locations/global/operations/operation-987654321-abcde" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json"

When in progress, only metadata exists; on success, done is true, and response contains the full resource with @type as google.cloud.aiplatform.v1beta1.Agent (including name, base_agent, system_instruction, etc.).

5. Query Existing Agent Configuration

curl -X GET "https://aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/global/agents/my-custom-agent" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "Content-Type: application/json"

Returns the current Agent’s tool list and environment settings, facilitating reconciliation with expected states in Infrastructure as Code or CI.

Adding an MCP entry in tools during creation declares an external server; the documentation emphasizes explaining header information and routing boundaries to the reader. If dynamically overriding MCP during interaction, use type: mcp_server in the tools of the data plane interactions.create—see the Gemini Interactions API Skill and Interactions API documentation for details; this Skill makes a cross-reference in its body.

Use Cases & Notes

Who it is for: Teams already using or planning to use the Gemini Enterprise Agent Platform who need to incorporate Agent definitions (instructions, mounts, tools) into automation pipelines or let Coding Agents generate curl/client code according to official contracts.

Points to note:

  1. The API is v1beta1; fields like base_agent depend on the models/templates currently available on the platform (the material example is antigravity-preview-05-2026).
  2. Creation is an LRO; the integration side must implement polling or equivalent asynchronous waiting and cannot assume POST returns a usable Agent synchronously.
  3. LOCATION and the endpoint region must be consistent, and you must confirm that the Managed Agents API is open in that region.
  4. MCP configuration involves credentials and outbound network; base_environment.network.allowlist needs to be tightened according to enterprise security policies. The "domain": "*" in the example is for structural illustration only.
  5. The control plane manages resources, while conversation execution belongs to the data plane; a complete chain usually requires combining with Skills like gemini-interactions-api.

Conclusion

gemini-agents-api converges the control plane REST flow for custom stateful Agents on Gemini Enterprise into an installable Agent Skill, reducing omissions when hand-writing endpoints and JSON. The installation entry is npx skills add google/skills. For Skill source code and full CRUD instructions, see the official repository: https://github.com/google/skills/tree/main/skills/cloud/gemini-agents-api.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye