<DocsApiEndpoint method="POST" path="/embeddings" slug="api-reference/embeddings/embedding" />

Vectorize content with an Isaacus embedding model.

## Example

<DocsCodeGroup>

```javascript
import Isaacus from 'isaacus';

const client = new Isaacus({
  apiKey: process.env['ISAACUS_API_KEY'],
});

const embeddingResponse = await client.embeddings.create({
  model: 'kanon-2-embedder',
  texts: [
    'Are restraints of trade enforceable under English law?',
    'What is a non-compete clause?',
  ],
});

console.log(embeddingResponse.embeddings);
```

```python
import os
from isaacus import Isaacus

client = Isaacus(
    api_key=os.environ.get("ISAACUS_API_KEY"),
)
embedding_response = client.embeddings.create(
    model="kanon-2-embedder",
    texts=["Are restraints of trade enforceable under English law?", "What is a non-compete clause?"],
)
print(embedding_response.embeddings)
```

</DocsCodeGroup>

## Authorizations

<DocsApiFieldGroup>
	<DocsApiField name="Authorization" type="string" id="parameter-authorization" location="header" required description={"An Isaacus-issued API key passed as a bearer token via the `Authorization` header in the format `Authorization: Bearer YOUR_API_KEY`."} />
</DocsApiFieldGroup>

## Request body

<DocsApiFieldGroup>
	<DocsApiField name="model" type="string" id="body-model" required description={"The ID of the [model](https://docs.isaacus.com/models#embedding) to use for embedding."} />

	<DocsApiField name="texts" types={[{"type":"array[string]","id":"body-texts-one-of-0"},{"type":"string","id":"body-texts-one-of-1"}]} required description={"The text or array of texts to embed.\n\nEach text must contain at least one non-whitespace character.\n\nNo more than 128 texts can be embedded in a single request."} />

	<DocsApiField name="task" types={[{"type":"null","id":"body-task-one-of-0"},{"type":"enum (retrieval/query | retrieval/document | null)","id":"body-task-one-of-1"}]} description={"The task the embeddings will be used for.\n\n`retrieval/query` is meant for queries and statements, and `retrieval/document` is meant for anything to be retrieved using query embeddings.\n\nIf `null`, which is the default setting, embeddings will not be optimized for any particular task."} />

	<DocsApiField name="overflow_strategy" types={[{"type":"null","id":"body-overflow-strategy-one-of-0"},{"type":"enum (drop_end | null)","id":"body-overflow-strategy-one-of-1"}]} description={"The strategy to employ when content exceeds the model's maximum input length.\n\n`drop_end`, which is the default setting, drops tokens from the end of the content exceeding the limit.\n\nIf `null`, an error will be raised if any content exceeds the model's maximum input length."} />

	<DocsApiField name="dimensions" types={[{"type":"integer","id":"body-dimensions-one-of-0"},{"type":"null","id":"body-dimensions-one-of-1"}]} description={"The number of dimensions the embeddings should have, not exceeding the maximum dimensions of the model.\n\nIf `null`, the model's default dimensions will be used."} />
</DocsApiFieldGroup>

## Response

Embeddings of texts produced by an Isaacus embedding model.

<DocsCodeBlock code={"{\n  \"embeddings\": [\n    {\n      \"index\": 0,\n      \"embedding\": [\n        -0.0258,\n        0.02062,\n        -0.0114\n      ]\n    },\n    {\n      \"index\": 1,\n      \"embedding\": [\n        -0.0358,\n        -0.0128,\n        0.00251\n      ]\n    }\n  ],\n  \"usage\": {\n    \"input_tokens\": 42\n  }\n}"} lang="json" label="200" />

<DocsApiFieldGroup>
	<DocsApiField name="embeddings" type="array[object]" id="response-embeddings" required description={"The embeddings of the inputs."}>
	<DocsApiFieldNested>
		<DocsApiField name="index" type="integer" id="response-embeddings-items-index" required nested description={"The position of the content in the input array of contents, starting from `0` (and, therefore, ending at the number of contents minus `1`)."} />

	<DocsApiField name="embedding" type="array[number]" id="response-embeddings-items-embedding" required nested description={"The embedding of the content represented as an array of floating point numbers."} />
	</DocsApiFieldNested>
</DocsApiField>

	<DocsApiField name="usage" type="object" id="response-usage" required description={"Statistics about the usage of resources in the process of embedding the inputs."}>
	<DocsApiFieldNested>
		<DocsApiField name="input_tokens" type="integer" id="response-usage-input-tokens" required nested description={"The number of tokens inputted to the model."} />
	</DocsApiFieldNested>
</DocsApiField>
</DocsApiFieldGroup>

See [making requests](/docs/api-reference/making-requests) for authentication, SDK usage, and [errors](/docs/api-reference/errors).