Table of Contents

Class GeminiManager

Namespace
Uralstech.UGemini

The class for accessing the Gemini API!

public class GeminiManager : Singleton<GeminiManager>
Inheritance
object
GeminiManager
Extension Methods

Fields

BaseServiceUri

The base URI to the Generative Language service.

public const string BaseServiceUri = "https://generativelanguage.googleapis.com"

Field Value

string

BetaApiUri

The v1 beta API URI to the Generative Language service.

public const string BetaApiUri = "https://generativelanguage.googleapis.com/v1beta"

Field Value

string

ProductionApiUri

The production v1 API URI to the Generative Language service.

public const string ProductionApiUri = "https://generativelanguage.googleapis.com/v1"

Field Value

string

Methods

Request(IGeminiDeleteRequest)

Computes a DELETE request on the Gemini API.

public Task Request(IGeminiDeleteRequest request)

Parameters

request IGeminiDeleteRequest

The request object.

Returns

Task

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response was not empty.

Request(IGeminiPostRequest)

Computes a POST request on the Gemini API.

public Task Request(IGeminiPostRequest request)

Parameters

request IGeminiPostRequest

The request object.

Returns

Task

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response was not empty.

Request<TResponse>(IGeminiGetRequest)

Computes a GET request on the Gemini API.

public Task<TResponse> Request<TResponse>(IGeminiGetRequest request)

Parameters

request IGeminiGetRequest

The request object.

Returns

Task<TResponse>

The computed response.

Type Parameters

TResponse

The response type. For example, a request of type GeminiChatRequest corresponds to a response type of GeminiChatResponse, and a request of type GeminiTokenCountRequest corresponds to a response of type GeminiTokenCountResponse.

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response could not be parsed.

Request<TResponse>(IGeminiMultiPartPostRequest)

Computes a multi-part POST request on the Gemini API.

public Task<TResponse> Request<TResponse>(IGeminiMultiPartPostRequest request)

Parameters

request IGeminiMultiPartPostRequest

The request object.

Returns

Task<TResponse>

The computed response.

Type Parameters

TResponse

The response type. For example, a request of type GeminiChatRequest corresponds to a response type of GeminiChatResponse, and a request of type GeminiTokenCountRequest corresponds to a response of type GeminiTokenCountResponse.

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response could not be parsed.

Request<TResponse>(IGeminiPatchRequest)

Computes a PATCH request on the Gemini API.

public Task<TResponse> Request<TResponse>(IGeminiPatchRequest request)

Parameters

request IGeminiPatchRequest

The request object.

Returns

Task<TResponse>

The computed response.

Type Parameters

TResponse

The response type. For example, a request of type GeminiChatRequest corresponds to a response type of GeminiChatResponse, and a request of type GeminiTokenCountRequest corresponds to a response of type GeminiTokenCountResponse.

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response could not be parsed.

Request<TResponse>(IGeminiPostRequest)

Computes a POST request on the Gemini API.

public Task<TResponse> Request<TResponse>(IGeminiPostRequest request)

Parameters

request IGeminiPostRequest

The request object.

Returns

Task<TResponse>

The computed response.

Type Parameters

TResponse

The response type. For example, a request of type GeminiChatRequest corresponds to a response type of GeminiChatResponse, and a request of type GeminiTokenCountRequest corresponds to a response of type GeminiTokenCountResponse.

Exceptions

GeminiRequestException

Thrown if the API request fails.

GeminiResponseParsingException

Thrown if the response could not be parsed.

SetApiKey(string)

Sets the Gemini API key.

public void SetApiKey(string apiKey)

Parameters

apiKey string

The new API key.

StreamRequest<TResponse>(IGeminiStreamablePostRequest<TResponse>)

Computes a streaming POST request on the Gemini API.

public Task<TResponse> StreamRequest<TResponse>(IGeminiStreamablePostRequest<TResponse> request) where TResponse : IAppendableData<TResponse>

Parameters

request IGeminiStreamablePostRequest<TResponse>

The request object.

Returns

Task<TResponse>

The computed response.

Type Parameters

TResponse

The response type. For example, a request of type GeminiChatRequest corresponds to a response type of GeminiChatResponse, and a request of type GeminiTokenCountRequest corresponds to a response of type GeminiTokenCountResponse.

Remarks

Use callbacks in the request object to receive the streamed data.

Exceptions

GeminiRequestException

Thrown if the API request fails.