/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-NamestringheaderThe name of the project that is making the request.
Request body
application/json
embedding_typesarray of stringSpecifies 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 stringAn 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`.
Show child attributes
input_typestringSpecifies 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.
modelstringID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed).
textsarray of stringAn array of strings for the model to embed. Maximum number of texts per call is `96`.
Show child attributes
truncatestringOne 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.
{
"embedding_types": [
"base64"
],
"images": [
"string"
],
"input_type": "classification",
"model": "string",
"texts": [
"string"
],
"truncate": "END"
}Responses
Headers
X-API-WarningThe name of the project that is making the request.
oneOf · 2 options
embeddingsarray of array of numberrequiredAn 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
idstringrequiredimagesarray of objectThe image entries for which embeddings were returned.
Show child attributes
Show array items
bit_depthnumber · int64requiredBit depth of the image
formatstringrequiredFormat of the image
heightnumber · int64requiredHeight of the image in pixels
widthnumber · int64requiredWidth of the image in pixels
metaobjectShow child attributes
api_versionobjectShow child attributes
is_deprecatedbooleanis_experimentalbooleanversionstringrequiredbilled_unitsobjectShow child attributes
classificationsnumberThe number of billed classifications units.
image_tokensnumberThe number of billed image tokens.
imagesnumberThe number of billed images.
input_tokensnumberThe number of billed input tokens.
output_tokensnumberThe number of billed output tokens.
pagesnumberThe number of billed pages parsed.
search_unitsnumberThe number of billed search units.
cached_tokensnumberThe number of prompt tokens that hit the inference cache.
tokensobjectShow child attributes
input_tokensnumberThe number of tokens used as input to the model.
output_tokensnumberThe number of tokens produced by the model.
warningsarray of stringShow child attributes
response_typestringtextsarray of stringrequiredThe text entries for which embeddings were returned.
Show child attributes
embeddingsobjectrequiredAn 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 stringAn 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 integerAn 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 numberAn array of float embeddings.
Show child attributes
Show array items
int8array of array of integerAn array of signed int8 embeddings. Each value is between -128 and 127.
Show child attributes
Show array items
ubinaryarray of array of integerAn 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 integerAn array of unsigned int8 embeddings. Each value is between 0 and 255.
Show child attributes
Show array items
Show array items
idstringrequiredimagesarray of objectThe image entries for which embeddings were returned.
Show child attributes
response_typestringtextsarray of stringThe text entries for which embeddings were returned.
Show child attributes
{
"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"
]
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}idstringmessagestring{
"id": "string",
"message": "string"
}