Table of Contents

Class GeminiAnswerRequest

Generates a grounded answer from the model.

public class GeminiAnswerRequest : IGeminiPostRequest, IGeminiRequest
Inheritance
GeminiAnswerRequest
Implements
Extension Methods

Remarks

Only available in the beta API.

Constructors

GeminiAnswerRequest(GeminiModelId, bool)

Creates a new GeminiAnswerRequest.

public GeminiAnswerRequest(GeminiModelId model, bool useBetaApi = true)

Parameters

model GeminiModelId

The model to use.

useBetaApi bool

Should the request use the Beta API?

Remarks

Only available in the beta API.

Fields

AnswerStyle

Style in which answers should be returned.

public GeminiAnswerStyle AnswerStyle

Field Value

GeminiAnswerStyle

ApiVersion

The API version to use.

public string ApiVersion

Field Value

string

Contents

The content of the current conversation with the model.

public GeminiContent[] Contents

Field Value

GeminiContent[]

Remarks

For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request.

generateAnswer currently only supports queries in English.

InlinePassages

Passages provided inline with the request.

public GeminiGroundingPassages InlinePassages

Field Value

GeminiGroundingPassages

Remarks

This or SemanticRetriever are must be provided at a time.

Model

The model to use.

public GeminiModelId Model

Field Value

GeminiModelId

SafetySettings

A list of unique GeminiSafetySettings instances for blocking unsafe content.

public GeminiSafetySettings[] SafetySettings

Field Value

GeminiSafetySettings[]

Remarks

This will be enforced on Contents and Answer.
There should not be more than one setting for each GeminiSafetyHarmCategory type. The API will block any
contents and responses that fail to meet the thresholds set by these settings. This list overrides the default
settings for each GeminiSafetyHarmCategory specified in the SafetySettings. If there is
no GeminiSafetySettings for a given GeminiSafetyHarmCategory provided in the list, the API will use the
default safety setting for that category. Harm categories HateSpeech,
SexuallyExplicit, DangerousContent and
Harassment are supported.

SemanticRetriever

Content retrieved from resources created via the Semantic Retriever API.

public GeminiSemanticRetrieverConfig SemanticRetriever

Field Value

GeminiSemanticRetrieverConfig

Remarks

This or InlinePassages are must be provided at a time.

Temperature

Controls the randomness of the output.

public float Temperature

Field Value

float

Remarks

Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and
creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low
temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases.

Properties

AuthMethod

The preferred authentication method.

public GeminiAuthMethod AuthMethod { get; set; }

Property Value

GeminiAuthMethod

ContentType

The MIME type of the request content.

public string ContentType { get; }

Property Value

string

OAuthAccessToken

The OAuth access token to authenticate the request, if using OAuthAccessToken as AuthMethod.

public string OAuthAccessToken { get; set; }

Property Value

string

Methods

GetEndpointUri(GeminiRequestMetadata)

Gets the URI to the API endpoint.

public string GetEndpointUri(GeminiRequestMetadata metadata)

Parameters

metadata GeminiRequestMetadata

The metadata of the request to be carried out on the URI.

Returns

string

The URI.

GetUtf8EncodedData()

Converts the request object to a UTF-8 encoded string.

public string GetUtf8EncodedData()

Returns

string

The string data.