> For the complete documentation index, see [llms.txt](https://docs.aibrow.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aibrow.ai/examples/embedding-api.md).

# Embedding API

AiBrow allows you to create embeddings from any piece of text. These can then be stored and searched over to find similar text to a new input

```javascript
import AI from '@aibrow/web'

// Create the session
const session = await AI.AIBrow.Embedding.create()

// Generate embeddings for known data
const data = {
  '1': 'data1',
  '2': 'data2',
  ...
}
const dataIds = Object.keys(data)
const vectors = await session.get(dataIds.map((id) => data[id]))
const embeddings = dataIds.map((id, index) => ({ id, vector: vectors[index] })

// Sort the list of embeddings by the most similar
const search = await session.get('search data')
const results = session.findSimilar(embeddings, search)
console.log(data[results[0].id])

```
