Table of Contents

Class AgentsClient

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

A client for the managed Agents API (/agents): create reusable agent definitions (base agent, agent configuration, system instruction, tools and base environment) and reference them from interactions. Follows python-genai's client.agents (experimental).

public class AgentsClient : AgentApiClientBase
Inheritance
AgentsClient
Inherited Members
Extension Methods

Constructors

AgentsClient(IPlatformAdapter, HttpClient?, ILogger?)

Initializes a new instance of the AgentsClient class.

public AgentsClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)

Parameters

platform IPlatformAdapter

The platform adapter (Google AI or Vertex AI).

httpClient HttpClient

Optional HTTP client.

logger ILogger

Optional logger.

Methods

CreateAsync(Agent, CancellationToken)

Creates an agent (POST /agents).

public Task<Agent> CreateAsync(Agent agent, CancellationToken cancellationToken = default)

Parameters

agent Agent

The agent definition.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Agent>

The created agent.

DeleteAsync(string, CancellationToken)

Deletes an agent (DELETE /agents/{id}).

public Task DeleteAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The agent ID.

cancellationToken CancellationToken

A cancellation token.

Returns

Task

A task that completes when the agent has been deleted.

GetAsync(string, CancellationToken)

Gets an agent (GET /agents/{id}).

public Task<Agent> GetAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The agent ID (an agents/ prefix is accepted).

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Agent>

The agent.

ListAllAsync(int?, string?, CancellationToken)

Lists all agents, following page tokens.

public IAsyncEnumerable<Agent> ListAllAsync(int? pageSize = null, string? parent = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

The page size.

parent string

Optional parent filter.

cancellationToken CancellationToken

A cancellation token.

Returns

IAsyncEnumerable<Agent>

The agents.

ListAsync(int?, string?, string?, CancellationToken)

Lists one page of agents (GET /agents).

public Task<ListAgentsResponse> ListAsync(int? pageSize = null, string? pageToken = null, string? parent = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

The maximum number of agents per page.

pageToken string

The page token of a previous call.

parent string

Optional parent filter (sent as the parent query parameter).

cancellationToken CancellationToken

A cancellation token.

Returns

Task<ListAgentsResponse>

The page.