# Embedding API

The Embedding API allows you to generate high-quality vector representations (embeddings) of text inputs. These embeddings can be used for a variety of tasks such as semantic search, text classification, clustering, and more. This API is fully compatible with the OpenAI SDK, making it easy to integrate into your existing workflows.

### Base URL

<https://api.netmind.ai/inference-api/openai/v1>

### Authentication

To use the API, you need to obtain a Netmind AI API Key. For detailed instructions, please refer to the [authentication documentation](https://netmind-power.gitbook.io/netmind-power-documentation/api/api-token).

### Supported Models

* nvidia/NV-Embed-v2
* dunzhang/stella\_en\_1.5B\_v5
* BAAI/bge-m3

### Usage Examples

#### Python Client

The Embedding API is compatible with the OpenAI Python SDK. Below is an example of how to use it

```python
from openai import OpenAI

# Initialize the client with NetMind API base URL and your API key
client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.netmind.ai/inference-api/openai/v1"
)

# Generate embeddings
response = client.embeddings.create(
    input="This is a sample text to embed.",
    model="nvidia/NV-Embed-v2",
    encoding_format="float" # only support float now
)

# Access the embedding
embedding = response.data[0].embedding
print(embedding)
```

#### CURL Example

```sh
# Set your API key
export API_KEY="<YOUR Netmind AI API Key>"

curl "https://api.netmind.ai/inference-api/openai/v1/embeddings" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d $'{
    "model": "nvidia/NV-Embed-v2",
    "input": "This is a sample text to embed.",
    "encoding_format": "float" # only support float now
}'
```

**BAAI/bge-m3 Example**

The `BAAI/bge-m3` model is a specialized embedding model designed to generate high-quality vector representations of text. It supports multiple encoding types, including `dense` (default), `sparse`, and `colbert` (Multi-Vector). For more details, please refer to the [Hugging Face model card](https://huggingface.co/BAAI/bge-m3).

```sh
# Set your API key
export API_KEY="<YOUR Netmind AI API Key>"

curl "https://api.netmind.ai/inference-api/openai/v1/embeddings" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  -d $'{
    "model": "BAAI/bge-m3",
    "input": "This is a sample text to embed.",
    "encoding_format": "float", # only support float now
    "encoding_type": "dense" # [dense, sparse, colbert]
}'
```
