API version: 0.3.0

---

# Text embedding

The text embedding search step is a single task, executable within [`POST /search`](/api/post-search.md) requests.

It turns a text into a vector with an embedding provider of the [configuration](/reference/configuration.md), e.g. for
the kNN query of a later [Elasticsearch step](/reference/search/elasticsearch-query-dsl-mixin.md). It does not search
itself. See the [vector search example](/reference/search/elasticsearch-query-dsl-mixin/vector-search.md).

## Security aspects

Every call of this step is a request to the embedding provider, which can cost money. The step therefore requires a
token with the capability `embedding.create`, see [roles and capabilities](/reference/roles-and-capabilities.md).
Requests without it, including anonymous ones, are answered with `403 Forbidden`.

## Input parameters

- `provider`: Required, string. The name of the embedding provider. Use the provider which calculated the vectors that
  are searched: vectors of different models can not be compared.

## Input query

The query is the text, a non-empty string of at most 8192 characters. It can also be an expression in `{{ }}`, which
returns the text, e.g. `{{ text }}` for a [saved search](/guide/search/saved-searches.md) with the parameter `text`.

## Step result

- `vector`: List of numbers, the vector of the text.
- `provider`: Name of the embedding provider.
- `dimensions`: Number of dimensions of the vector.

```json
{
  "vector": [
    -0.0441,
    0.0613,
    0.0249,
    "..."
  ],
  "provider": "test",
  "dimensions": 384
}
```

Later steps read the vector from their parameters, e.g. with the expression `{{ stepResults[0].vector }}`.

## Errors

- `400 Bad Request`: The provider is not configured, or the text is missing, empty or too long.
- `403 Forbidden`: The token does not have the capability `embedding.create`.
- `503 Service Unavailable`: The provider could not be reached or failed. The request to the provider is limited by the
  `timeoutInSeconds` of the provider.

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [Parameterized element ids](/reference/search/element-hydration/parameterized-element-ids.md)

Next: [Schemas](/reference/schemas.md)
