Table of Contents

Class Client

Namespace
Google.GenAI
Assembly
Google.GenAI.dll

Client for making synchronous requests. Using this client to make a request to Gemini Developer API or Vertex AI API.

public sealed class Client : IDisposable, IAsyncDisposable
Inheritance
Client
Implements
Inherited Members
Extension Methods

Constructors

Client(bool?, bool?, string?, ICredential?, string?, string?, HttpOptions?, ClientOptions?)

Constructs a Client instance with the given parameters.

public Client(bool? enterprise = null, bool? vertexAI = null, string? apiKey = null, ICredential? credential = null, string? project = null, string? location = null, HttpOptions? httpOptions = null, ClientOptions? clientOptions = null)

Parameters

enterprise bool?

Optional Boolean for whether to use Gemini Enterprise Agent Platform APIs. If neither is specified here nor in the environment variable, defaults to false. If both enterprise and vertexAI are set, and they have different values, an ArgumentException will be thrown.

vertexAI bool?

Optional Boolean for whether to use Vertex AI APIs (now Gemini Enterprise Agent Platform). If not specified here nor in the environment variable, defaults to false. NOTE: Use enterprise parameter from now on. enterprise parameter takes precedence over this flag. If both enterprise and vertexAI are set, and they have different values, an ArgumentException will be thrown.

apiKey string

Optional String for the API key. Gemini API only.

credential ICredential

Optional GoogleCredential. Vertex AI only.

project string

Optional String for the project ID. Vertex AI APIs only. Find your project ID.

location string

Optional String for the location. Vertex AI APIs only.

httpOptions HttpOptions

Optional HttpOptions for sending HTTP requests.

clientOptions ClientOptions

Optional ClientOptions for configuring the client.

Exceptions

ArgumentException

Thrown if the project/location and API key are set together.

Properties

Batches

public Batches Batches { get; }

Property Value

Batches

Caches

public Caches Caches { get; }

Property Value

Caches

Files

public Files Files { get; }

Property Value

Files

Live

public Live Live { get; }

Property Value

Live

Models

public Models Models { get; }

Property Value

Models

Operations

public Operations Operations { get; }

Property Value

Operations

Tokens

public Tokens Tokens { get; }

Property Value

Tokens

Tunings

public Tunings Tunings { get; }

Property Value

Tunings

Methods

Dispose()

Disposes the client and its underlying resources.

public void Dispose()

DisposeAsync()

Asynchronously disposes the client and its underlying resources.

public ValueTask DisposeAsync()

Returns

ValueTask

A ValueTask that represents the asynchronous dispose operation.

setDefaultBaseUrl(string?, string?)

public static void setDefaultBaseUrl(string? vertexBaseUrl, string? geminiBaseUrl)

Parameters

vertexBaseUrl string
geminiBaseUrl string