Class GeminiEmbedContentRequest
Generates an embedding from the model.
public class GeminiEmbedContentRequest : IGeminiPostRequest, IGeminiRequest
- Inheritance
-
GeminiEmbedContentRequest
- Implements
- Extension Methods
Constructors
GeminiEmbedContentRequest(GeminiModelId, bool)
Creates a new GeminiEmbedContentRequest.
public GeminiEmbedContentRequest(GeminiModelId model, bool useBetaApi = false)
Parameters
model
GeminiModelIdThe model to use.
useBetaApi
boolShould the request use the Beta API?
Fields
ApiVersion
The API version to use.
public string ApiVersion
Field Value
Content
The content to embed. Only the Text fields will be counted.
public GeminiContent Content
Field Value
Model
The model to use.
public GeminiModelId Model
Field Value
OutputDimensionality
Optional reduced dimension for the output embedding.
public int OutputDimensionality
Field Value
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
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
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
ContentType
The MIME type of the request content.
public string ContentType { get; }
Property Value
OAuthAccessToken
The OAuth access token to authenticate the request, if using OAuthAccessToken as AuthMethod.
public string OAuthAccessToken { get; set; }
Property Value
Methods
GetEndpointUri(GeminiRequestMetadata)
Gets the URI to the API endpoint.
public string GetEndpointUri(GeminiRequestMetadata metadata)
Parameters
metadata
GeminiRequestMetadataThe 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.