# Embeddings

> Turn texts into numbers that stand for their meaning, to search by meaning or find similar things.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://ai.docs.sypnia.com/using/embeddings/

For agents: POST /v1/embeddings (OpenAI-compatible): model task:embed (or own task), input string or array (up to 256 items, each within the model's context), dimensions where the model supports it, encoding_format float|base64. SDK ai.embed({task, case, input}). The route pins the embedding model: changing it means re-embedding (vectors of different models are not comparable); ai routes apply warns. Store vectors in Postgres with pgvector in Sypnia Data. Priced per input token.

An **embedding** is a list of numbers that stands for the meaning of a text. Texts that mean similar things get similar numbers, so you can search by meaning: a customer types «something without gluten» and finds the gluten-free loaf, even though the words differ.

```ts
const { vectors } = await ai.embed({
  task: 'embed',
  case: 'find-products',
  input: products.map((p) => `${p.name}. ${p.description}`),
});
```

Keep the vectors next to your data. In [Sypnia Data](https://data.docs.sypnia.com/), a `vector` column (Postgres with pgvector) holds them, and one query finds the nearest products to the customer's words.

|                    |                                                                                  |
| ------------------ | -------------------------------------------------------------------------------- |
| Inputs per request | up to 256 texts, each within the model's limit                                   |
| Options            | `dimensions` where the model supports it; `encoding_format`: `float` or `base64` |
| Price              | per token read; nothing is written                                               |

> **Warning: One model per set of vectors**
>
> Vectors made by different models cannot be compared. The route for an embedding task keeps its model; if you change it, embed everything again. `ai routes apply` warns you before such a change.
