Method: models.embedText

Generates an embedding from the model given an input message.

HTTP request

POST https://generativelanguage.googleapis.com/v1beta3/{model=models/*}:embedText

The URL uses gRPC Transcoding syntax.

For example:

curl https://generativelanguage.googleapis.com/v1beta2/models/embedding-gecko-001:embedText?key=$PALM_API_KEY \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{"text": "say something nice!"}'
{
  "embedding": {
    "value": [
      0.0011238843,
      -0.040586308,
      -0.013174802,
      0.015497498,
      ...
    ]
  }
}

Path parameters

Parameters
model

string

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

Request body

The request body contains data with the following structure:

JSON representation
{
  "text": string
}
Fields
text

string

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

Response body

The response to a EmbedTextRequest.

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

JSON representation
{
  "embedding": {
    object (Embedding)
  }
}
Fields
embedding

object (Embedding)

Output only. The embedding generated from the input text.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/generative-language

For more information, see the Authentication Overview.