# 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])

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aibrow.ai/examples/embedding-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
