Method: models.batchEmbedText

Generates multiple embeddings from the model given input text in a synchronous call.

HTTP request

POST https://generativelanguage.googleapis.com/v1beta/{model=models/*}:batchEmbedText

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
model

string

Required. The name of the Model to use for generating the embedding. Examples: models/embedding-gecko-001

Request body

The request body contains data with the following structure:

JSON representation
{
  "texts": [
    string
  ],
  "requests": [
    {
      object (EmbedTextRequest)
    }
  ]
}
Fields
texts[]

string

Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown.

requests[]

object (EmbedTextRequest)

Optional. Embed requests for the batch. Only one of texts or requests can be set.

Response body

The response to a EmbedTextRequest.

If successful, the response body contains data with the following structure:

JSON representation
{
  "embeddings": [
    {
      object (Embedding)
    }
  ]
}
Fields
embeddings[]

object (Embedding)

Output only. The embeddings generated from the input text.

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.

EmbedTextRequest

Request to get a text embedding from the model.

JSON representation
{
  "model": string,
  "text": string
}
Fields
model

string

Required. The model name to use with the format model=models/{model}.

text

string

Optional. The free-form input text that the model will turn into an embedding.