Skip to main content
Cohere

Search documentation

Type to search this documentation.

Embed API (v1)

POST/v1/embedEmbed API (v1)

This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents.

Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.

If you want to learn more how to use the embedding model, have a look at the Semantic Search Guide.

Parameters

X-Client-Namestringheader

The name of the project that is making the request.

Request body

application/json
object
embedding_typesarray of string

Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types. * `"float"`: Use this when you want to get back the default float embeddings. Supported with all Embed models. * `"int8"`: Use this when you want to get back signed int8 embeddings. Supported with Embed v3.0 and newer Embed models. * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Supported with Embed v3.0 and newer Embed models. * `"binary"`: Use this when you want to get back signed binary embeddings. Supported with Embed v3.0 and newer Embed models. * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Supported with Embed v3.0 and newer Embed models.

Show child attributes
imagesarray of string

An array of image data URIs for the model to embed. The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`.

minItems 1

Show child attributes

minItems 1

input_typestring

Specifies the type of input passed to the model. Required for embedding models v3 and higher. - `"search_document"`: Used for embeddings stored in a vector database for search use-cases. - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents. - `"classification"`: Used for embeddings passed through a text classifier. - `"clustering"`: Used for the embeddings run through a clustering algorithm. - `"image"`: Used for embeddings with image input.

one of "search_document", "search_query", "classification", "clustering", "image"

modelstring

ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed).

textsarray of string

An array of strings for the model to embed. Maximum number of texts per call is `96`.

maxItems 96 · minItems 1

Show child attributes

maxItems 96 · minItems 1

truncatestring

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length. Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model. If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

one of "NONE", "START", "END" · default "END"

Example request
{
  "embedding_types": [
    "base64"
  ],
  "images": [
    "string"
  ],
  "input_type": "classification",
  "model": "string",
  "texts": [
    "string"
  ],
  "truncate": "END"
}

Responses

200OKapplication/json

Headers

X-API-Warning

The name of the project that is making the request.

value
oneOf · 2 options
Option 1objectEmbedFloatsResponse
embeddingsarray of array of numberrequired

An array of embeddings, where each embedding is an array of floats. The length of the `embeddings` array will be the same as the length of the original `texts` array.

Show child attributes
Show array items
idstringrequired
imagesarray of object

The image entries for which embeddings were returned.

Show child attributes
Show array items
bit_depthnumber · int64required

Bit depth of the image

formatstringrequired

Format of the image

heightnumber · int64required

Height of the image in pixels

widthnumber · int64required

Width of the image in pixels

metaobject
Show child attributes
api_versionobject
Show child attributes
is_deprecatedboolean
is_experimentalboolean
versionstringrequired
billed_unitsobject
Show child attributes
classificationsnumber

The number of billed classifications units.

image_tokensnumber

The number of billed image tokens.

imagesnumber

The number of billed images.

input_tokensnumber

The number of billed input tokens.

output_tokensnumber

The number of billed output tokens.

pagesnumber

The number of billed pages parsed.

search_unitsnumber

The number of billed search units.

cached_tokensnumber

The number of prompt tokens that hit the inference cache.

tokensobject
Show child attributes
input_tokensnumber

The number of tokens used as input to the model.

output_tokensnumber

The number of tokens produced by the model.

warningsarray of string
Show child attributes
response_typestring

one of "embeddings_floats", "embeddings_by_type"

textsarray of stringrequired

The text entries for which embeddings were returned.

Show child attributes
Option 2objectEmbedByTypeResponse
embeddingsobjectrequired

An object with different embedding types. The length of each embedding type array will be the same as the length of the original `texts` array.

Show child attributes
base64array of string

An array of base64 embeddings. Each string is the result of appending the float embedding bytes together and base64 encoding that.

Show child attributes
binaryarray of array of integer

An array of packed signed binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between -128 and 127.

Show child attributes
Show array items
floatarray of array of number

An array of float embeddings.

Show child attributes
Show array items
int8array of array of integer

An array of signed int8 embeddings. Each value is between -128 and 127.

Show child attributes
Show array items
ubinaryarray of array of integer

An array of packed unsigned binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between 0 and 255.

Show child attributes
Show array items
uint8array of array of integer

An array of unsigned int8 embeddings. Each value is between 0 and 255.

Show child attributes
Show array items
Show array items
idstringrequired
imagesarray of object

The image entries for which embeddings were returned.

Show child attributes

Items: Image ↑

metaobjectApiMeta ↑
response_typestring

one of "embeddings_floats", "embeddings_by_type"

textsarray of string

The text entries for which embeddings were returned.

Show child attributes
Example response
{
  "embeddings": {
    "base64": [
      "string"
    ],
    "binary": [
      [
        0
      ]
    ],
    "float": [
      [
        0
      ]
    ],
    "int8": [
      [
        0
      ]
    ],
    "ubinary": [
      [
        0
      ]
    ],
    "uint8": [
      [
        0
      ]
    ]
  },
  "id": "string",
  "images": [
    {
      "bit_depth": 0,
      "format": "string",
      "height": 0,
      "width": 0
    }
  ],
  "meta": {
    "api_version": {
      "is_deprecated": true,
      "is_experimental": true,
      "version": "string"
    },
    "billed_units": {
      "classifications": 0,
      "image_tokens": 0,
      "images": 0,
      "input_tokens": 0,
      "output_tokens": 0,
      "pages": 0,
      "search_units": 0
    },
    "cached_tokens": 0,
    "tokens": {
      "input_tokens": 0,
      "output_tokens": 0
    },
    "warnings": [
      "string"
    ]
  },
  "response_type": "embeddings_by_type",
  "texts": [
    "string"
  ]
}
400This error is returned when the request is not well formed. This could be because: - JSON is invalid - The request is missing required fields - The request contains an invalid combination of fields application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
401This error indicates that the operation attempted to be performed is not allowed. This could be because: - The api token is invalid - The user does not have the necessary permissions application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
403This error indicates that the operation attempted to be performed is not allowed. This could be because: - The api token is invalid - The user does not have the necessary permissions application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
404This error is returned when a resource is not found. This could be because: - The endpoint does not exist - The resource does not exist eg model id, dataset id application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
422This error is returned when the request is not well formed. This could be because: - JSON is invalid - The request is missing required fields - The request contains an invalid combination of fields application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
429Too many requestsapplication/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
498This error is returned when a request or response contains a deny-listed token. application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
499This error is returned when a request is cancelled by the user. application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
500This error is returned when an uncategorised internal server error occurs. application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
501This error is returned when the requested feature is not implemented. application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
503This error is returned when the service is unavailable. This could be due to: - Too many users trying to access the service at the same time application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
504This error is returned when a request to the server times out. This could be due to: - An internal services taking too long to respond application/json
object
idstring
messagestring
Example response
{
  "id": "string",
  "message": "string"
}
Documentation menu