---
title: "Embed API (v2)"
method: POST
path: "/v2/embed"
---

# Embed API (v2)

`POST /v2/embed`

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

Embeddings can be used to create text 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](https://docs.cohere.com/docs/semantic-search).

## Headers

- `X-Client-Name` string

## Request body

- object
  - `texts` string[] — An array of strings for the model to embed. Maximum number of texts per call is `96`.
  - `images` 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`.
  - `model` string, required — ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed).
  - `input_type` 'search_document' | 'search_query' | 'classification' | 'clustering' | 'image', required — 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.
  - `inputs` EmbedInput[] — An array of inputs for the model to embed. Maximum number of inputs per call is `96`. An input can contain a mix of text and image components.
    - `content` EmbedContent[], required — An array of objects containing the input data for the model to embed.
      - union
        - object — Image content of the input. Supported with Embed v3.0 and newer models.
          - `type` 'text' | 'image_url'
          - `image_url` EmbedImageUrl — Base64 url of image.
            - `url` string, required
        - object — Text content of the input.
          - `type` 'text' | 'image_url'
          - `text` string
  - `max_tokens` integer — The maximum number of tokens to embed per input. If the input text is longer than this, it will be truncated according to the `truncate` parameter.
  - `output_dimension` integer — The number of dimensions of the output embedding. This is only available for `embed-v4` and newer models. Possible values are `256`, `512`, `1024`, and `1536`. The default is `1536`.
  - `embedding_types` EmbeddingType[] — Specifies the types of embeddings you want to get back. 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. * `"base64"`: Use this when you want to get back base64 embeddings. Supported with Embed v3.0 and newer Embed models.
  - `truncate` 'NONE' | 'START' | 'END' — 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.
  - `priority` integer — Controls how early the request is handled. Lower numbers indicate higher priority (default: 0, the highest). When the system is under load, higher-priority requests are processed first and are the least likely to be dropped.

## Response `200`

OK

- EmbedByTypeResponse
  - `response_type` 'embeddings_floats' | 'embeddings_by_type'
  - `id` string, required
  - `embeddings` object, required — 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.
    - `float` array[] — An array of float embeddings.
      - number[]
    - `int8` array[] — An array of signed int8 embeddings. Each value is between -128 and 127.
      - integer[]
    - `uint8` array[] — An array of unsigned int8 embeddings. Each value is between 0 and 255.
      - integer[]
    - `binary` array[] — 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.
      - integer[]
    - `ubinary` array[] — 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.
      - integer[]
    - `base64` string[] — An array of base64 embeddings. Each string is the result of appending the float embedding bytes together and base64 encoding that.
  - `texts` string[] — The text entries for which embeddings were returned.
  - `images` Image[] — The image entries for which embeddings were returned.
    - `width` number, required — Width of the image in pixels
    - `height` number, required — Height of the image in pixels
    - `format` string, required — Format of the image
    - `bit_depth` number, required — Bit depth of the image
  - `meta` ApiMeta
    - `api_version` object
      - `version` string, required
      - `is_deprecated` boolean
      - `is_experimental` boolean
    - `billed_units` object
      - `images` number — The number of billed images.
      - `input_tokens` number — The number of billed input tokens.
      - `image_tokens` number — The number of billed image tokens.
      - `output_tokens` number — The number of billed output tokens.
      - `search_units` number — The number of billed search units.
      - `classifications` number — The number of billed classifications units.
    - `tokens` object
      - `input_tokens` number — The number of tokens used as input to the model.
      - `output_tokens` number — The number of tokens produced by the model.
    - `cached_tokens` number — The number of prompt tokens that hit the inference cache.
    - `warnings` string[]

## Other responses

- `400` — This 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
- `401` — This 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
- `403` — This 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
- `404` — This 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
- `422` — This 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
- `429` — Too many requests
- `498` — This error is returned when a request or response contains a deny-listed token.
- `499` — This error is returned when a request is cancelled by the user.
- `500` — This error is returned when an uncategorised internal server error occurs.
- `501` — This error is returned when the requested feature is not implemented.
- `503` — This 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
- `504` — This error is returned when a request to the server times out. This could be due to: - An internal services taking too long to respond

---

[API](https://skmtc.net/cohere-ai/apis/api-reference.md) · [All operations](https://skmtc.net/cohere-ai/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cohere-ai/api-reference/versions/dbed69eda210/schema)
