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
platformIPlatformAdapterThe platform adapter (Google AI or Vertex AI).
httpClientHttpClientOptional HTTP client.
loggerILoggerOptional logger.
Methods
CreateAsync(Agent, CancellationToken)
Creates an agent (POST /agents).
public Task<Agent> CreateAsync(Agent agent, CancellationToken cancellationToken = default)
Parameters
agentAgentThe agent definition.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteAsync(string, CancellationToken)
Deletes an agent (DELETE /agents/{id}).
public Task DeleteAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe agent ID.
cancellationTokenCancellationTokenA 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
idstringThe agent ID (an
agents/prefix is accepted).cancellationTokenCancellationTokenA cancellation token.
Returns
ListAllAsync(int?, string?, CancellationToken)
Lists all agents, following page tokens.
public IAsyncEnumerable<Agent> ListAllAsync(int? pageSize = null, string? parent = null, CancellationToken cancellationToken = default)
Parameters
pageSizeint?The page size.
parentstringOptional parent filter.
cancellationTokenCancellationTokenA 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
pageSizeint?The maximum number of agents per page.
pageTokenstringThe page token of a previous call.
parentstringOptional parent filter (sent as the
parentquery parameter).cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<ListAgentsResponse>
The page.