Appearance
Llama 3.2 nv embedqa 1b v2 ​
The Text-2-Vector API allows you to generate vector embeddings for input text, which can be used in machine learning models and algorithms. The API also provides endpoints to list available models.
Endpoints ​
1. Create Embedding ​
POST /v1/embeddings
Description ​
Generates an embedding vector for the given input text.
Request Body ​
json
{
"input": "The quick brown fox jumped over the lazy dog",
"model": "nvidia/llama-3.2-nv-embedqa-1b-v2",
"encoding_format": "float",
"dimensions": 512,
"user": "user-1234"
}| Field | Type | Required | Description |
|---|---|---|---|
input | string/array | Yes | Input text or tokens to embed. |
model | string | Yes | ID of the model to use. |
encoding_format | string | No | Format of the embeddings (float or base64). Default: float. |
dimensions | integer | No | Number of dimensions for the output embeddings. |
user | string | No | User identifier for tracking purposes. |
Response ​
json
{
"object": "list",
"model": "nvidia/llama-3.2-nv-embedqa-1b-v2",
"data": [
{
"index": 0,
"object": "embedding",
"embedding": [0.123, 0.456, 0.789, ...]
}
],
"usage": {
"prompt_tokens": 10,
"total_tokens": 12
}
}| Field | Type | Description |
|---|---|---|
object | string | Always "list". |
model | string | The model used to generate the embedding. |
data | array | List of embeddings generated. |
usage | object | Token usage details. |
2. List Models ​
GET /v1/models
Description ​
Lists all available models and their metadata.
Response ​
json
{
"object": "list",
"data": [
{
"id": "nvidia/llama-3.2-nv-embedqa-1b-v2",
"object": "model",
"created": 1672531200,
"owned_by": "SwissAI"
}
]
}| Field | Type | Description |
|---|---|---|
id | string | Model identifier. |
object | string | Always "model". |
created | integer | Unix timestamp of model creation. |
owned_by | string | Organization owning the model. |
Example Code Snippets ​
Note:
The production URL for this API is available in the corresponding plan for this model in the Digital Marketplace. To retrieve the URL:
- Navigate to the Digital Marketplace.
- Go to the Documentation section.
- Select the plan associated with the
Llama 3.2 nv embedqa 1b v2model.- Locate the production URL provided in the plan details.
- Set up the environment variable
API_URLto the production URL retrieved.
1. Using curl ​
Create Embedding ​
bash
curl -X POST $API_URL/v1/embeddings \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H ""
-d '{
"input": "The quick brown fox jumped over the lazy dog",
"model": "nvidia/llama-3.2-nv-embedqa-1b-v2",
"encoding_format": "float",
"dimensions": 512,
"user": "user-1234"
}'List Models ​
bash
curl -X GET $API_URL/v1/models \
-H "Authorization: Bearer $YOUR_API_KEY"2. Using Python (OpenAI Client) ​
Create Embedding ​
python
import os
import openai
client = openai.OpenAI(
api_key=os.getenv("YOUR_API_KEY"),
base_url=os.getenv("API_URL") + "/v1",
)
response = client.embeddings.create(
input="The quick brown fox jumped over the lazy dog",
model="nvidia/llama-3.2-nv-embedqa-1b-v2",
encoding_format="float",
dimensions=512,
user="user-1234"
)
print(response)List Models ​
python
import os
import openai
client = openai.OpenAI(
api_key=os.getenv("YOUR_API_KEY"),
base_url=os.getenv("API_URL") + "/v1",
)
response = client.models.list()
print(response)Replace YOUR_API_KEY with your actual API key to authenticate the requests. You can follow the procedure in Inference Endpoints Overview

