# uerying Embedding Models in inferia

inferia hosts multiple embedding models. This guide will walk through an example using **nomic-ai/nomic-embed-text-v1.5** to demonstrate how to query inferia with the embeddings API.

***

**Embedding Documents**

inferia embedding service is compatible with OpenAI’s API. You can refer to OpenAI’s embeddings guide and documentation for more details on embedding model usage.

The embedding model takes text as input and outputs a vector (a list of floating-point numbers) that can be used for tasks like similarity comparisons and search.

***

**Example: Embedding a Document**

python

```python
import dashflow  

client = dashflow.Client(  
    base_url="https://api.dashflow.ai/v1",  
    api_key="<DASHFLOW_API_KEY>",  
)  
response = client.embeddings.create(  
    model="nomic-ai/nomic-embed-text-v1.5",  
    input="search_document: Spiderman was a particularly entertaining movie with...",  
)  

print(response)  
```

This code embeds the text `"search_document: Spiderman was a particularly entertaining movie with..."` and returns a response similar to:

json

```python
{  
  "data": [  
    {  
      "embedding": [0.0063, 0.0118, ...],  
      "index": 0,  
      "object": "embedding"  
    }  
  ],  
  "model": "nomic-ai/nomic-embed-text-v1.5",  
  "object": "list",  
  "usage": {  
    "prompt_tokens": 12,  
    "total_tokens": 12  
  }  
}  
```

***

**Embedding Queries and Documents**

Nomic models have been fine-tuned to handle specific prefixes. Use `search_query:` for user queries and `search_document:` for documents.

For example, if you previously embedded movie reviews stored in a vector database, they should all include the prefix `search_document:`.

To retrieve recommendations based on a user query, embed the query as follows:

python

```python
import dashflow  

client = dashflow.Client(  
    base_url="https://api.dashflow.ai/v1",  
    api_key="<DASHFLOW_API_KEY>",  
)  

query = "I love superhero movies, any recommendations?"  
task_description = "Given a user query for movies, retrieve the relevant movie that can fulfill the query."  

query_emb = client.embeddings.create(  
    model="nomic-ai/nomic-embed-text-v1.5",  
    input=f"search_query: {query}"  
)  

print(query_emb)  
```

To see an end-to-end example using a MongoDB vector store and a inferia-hosted generation model for Retrieval-Augmented Generation (RAG), refer to the full inferiaRAG guide.

For more details on prefix usage in Nomic models, refer to Nomic's official documentation.

***

**Variable Dimensions**

inferia embedding models support variable embedding dimension sizes. To specify a custom dimension size, provide the `dimensions` parameter in the API request:

python

```python
import dashflow  

client = dashflow.Client(  
    base_url="https://api.dashflow.ai/v1",  
    api_key="<DASHFLOW_API_KEY>",  
)  

response = client.embeddings.create(  
    model="nomic-ai/nomic-embed-text-v1.5",  
    input="search_document: I like Christmas movies, can you make any recommendations?",  
    dimensions=128,  
)  

print(len(response.data[0].embedding))  
```

This allows you to customize the embedding size to suit your specific use case.

For more details, visit the inferiaAPI documentation at **dashflow.ai/docs**.
