Generates an embedding from the model given an input Content
.
HTTP request
POST https://generativelanguage.googleapis.com/v1/{model=models/*}:embedContent
Path parameters
Parameters | |
---|---|
model |
Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the Format: |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "content": { object ( |
Fields | |
---|---|
content |
Required. The content to embed. Only the |
taskType |
Optional. Optional task type for which the embeddings will be used. Can only be set for |
title |
Optional. An optional title for the text. Only applicable when TaskType is Note: Specifying a |
outputDimensionality |
Optional. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024, and the earlier model ( |
Response body
The response to an EmbedContentRequest
.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"embedding": {
object ( |
Fields | |
---|---|
embedding |
Output only. The embedding generated from the input content. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/generative-language
https://www.googleapis.com/auth/generative-language.tuning
https://www.googleapis.com/auth/generative-language.tuning.readonly
https://www.googleapis.com/auth/generative-language.retriever
https://www.googleapis.com/auth/generative-language.retriever.readonly
For more information, see the Authentication Overview.