Class GeminiManager
The class for accessing the Gemini API!
public class GeminiManager : Singleton<GeminiManager>
- Inheritance
-
objectGeminiManager
- 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
requestIGeminiDeleteRequestThe 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
requestIGeminiPostRequestThe 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
requestIGeminiGetRequestThe request object.
Returns
- Task<TResponse>
The computed response.
Type Parameters
TResponseThe 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
requestIGeminiMultiPartPostRequestThe request object.
Returns
- Task<TResponse>
The computed response.
Type Parameters
TResponseThe 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
requestIGeminiPatchRequestThe request object.
Returns
- Task<TResponse>
The computed response.
Type Parameters
TResponseThe 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
requestIGeminiPostRequestThe request object.
Returns
- Task<TResponse>
The computed response.
Type Parameters
TResponseThe 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
apiKeystringThe 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
requestIGeminiStreamablePostRequest<TResponse>The request object.
Returns
- Task<TResponse>
The computed response.
Type Parameters
TResponseThe 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.