列出代理¶
此 API 為 Beta 版。端點位於 /v1beta/。
GET https://generativelanguage.googleapis.com/v1beta/agents
列出所有代理。
參數¶
parent: required string
列出代理的父資源。格式: projects/{project}/locations/{location}
page_size: integer
page_token: string
範例請求
curl -X GET https://generativelanguage.googleapis.com/v1beta/agents \
-H "x-goog-api-key: $GEMINI_API_KEY"
from google import genai
client = genai.Client(http_options={"api_version": "v1beta"})
response = client.agents.list()
for agent in response.agents or []:
print(agent.id)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({apiVersion: 'v1beta'});
const agents = await ai.agents.list();
for (const agent of agents.agents ?? []) {
console.log(agent.id);
}
import com.google.genai.gaos.models.agents.Agent;
import com.google.genai.gaos.models.agents.AgentListResponse;
import com.google.genai.Client;
import com.google.genai.types.HttpOptions;
import com.google.genai.gaos.models.operations.ListAgentsResponse;
Client client =
Client.builder().httpOptions(HttpOptions.builder().apiVersion("v1beta").build()).build();
ListAgentsResponse response = client.agents.list().call();
List<Agent> agents =
response.agentListResponse().flatMap(AgentListResponse::agents).orElse(List.of());
for (Agent agent : agents) {
agent.id().ifPresent(System.out::println);
}
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, &genai.ClientConfig{
HTTPOptions: genai.HTTPOptions{APIVersion: "v1beta"},
})
if err != nil {
log.Fatal(err)
}
res, err := client.Agents.List(ctx, operations.ListAgentsRequest{})
if err != nil {
log.Fatal(err)
}
if res.AgentListResponse != nil {
for _, agent := range res.AgentListResponse.Agents {
if agent.ID != nil {
fmt.Println(*agent.ID)
}
}
}
}
回應¶
agents: Agent array
代理清單。
next_page_token: string
用於擷取下一頁結果的權杖。
範例回應
{
"agents": [
{
"description": "A helpful research assistant.",
"base_agent": "antigravity-preview-09-2026",
"id": "research-assistant-abc123",
"system_instruction": "You are a helpful research assistant.",
"tools": [
{
"type": "google_search"
}
]
}
]
}
資源¶
Agent¶
CreateAgent API 的代理定義。 此訊息是以註解剖析器為基礎的 JSON 剖析目標。 新格式:
{
"id": "customer-sentinel",
"base_agent": "",
"system_instruction": "...",
"base_environment": { "type": "remote", "sources": [...] },
"tools": [ {"type": "code_execution"} ]
}
屬性:
id: string
代理的唯一識別碼。
base_agent: string
要擴充的基礎代理。
system_instruction: string
代理的系統指令。
description: string
供開發人員快速閱讀與理解的代理說明。