Table of Contents

Class GeminiEmbedContentRequest

Generates an embedding from the model.

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

Constructors

GeminiEmbedContentRequest(GeminiModelId, bool)

public GeminiEmbedContentRequest(GeminiModelId model, bool useBetaApi = false)

Parameters

model GeminiModelId

The model to use.

useBetaApi bool

Should the request use the Beta API?

Fields

ApiVersion

The API version to use.

public string ApiVersion

Field Value

string

Content

The content to embed. Only the Text fields will be counted.

public GeminiContent Content

Field Value

GeminiContent

Model

The model to use.

public GeminiModelId Model

Field Value

GeminiModelId

OutputDimensionality

Optional reduced dimension for the output embedding.

public int OutputDimensionality

Field Value

int

Remarks

If set, excessive values in the output embedding are truncated from the end. Supported by
newer models since 2024, and the earlier model (models/embedding-001) cannot specify this value.

TaskType

Optional task type for which the embeddings will be used.

public GeminiEmbedTaskType TaskType

Field Value

GeminiEmbedTaskType

Remarks

Can only be set for "models/embedding-001" model.

Title

An optional title for the text. Only applicable when TaskType is RetrievalDocument.

public string Title

Field Value

string

Remarks

Specifying a this for RetrievalDocument provides better quality embeddings for retrieval.

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.