Skip to content

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"
}
FieldTypeRequiredDescription
inputstring/arrayYesInput text or tokens to embed.
modelstringYesID of the model to use.
encoding_formatstringNoFormat of the embeddings (float or base64). Default: float.
dimensionsintegerNoNumber of dimensions for the output embeddings.
userstringNoUser 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
  }
}
FieldTypeDescription
objectstringAlways "list".
modelstringThe model used to generate the embedding.
dataarrayList of embeddings generated.
usageobjectToken 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"
    }
  ]
}
FieldTypeDescription
idstringModel identifier.
objectstringAlways "model".
createdintegerUnix timestamp of model creation.
owned_bystringOrganization 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:

  1. Navigate to the Digital Marketplace.
  2. Go to the Documentation section.
  3. Select the plan associated with the Llama 3.2 nv embedqa 1b v2 model.
  4. Locate the production URL provided in the plan details.
  5. Set up the environment variable API_URL to the production URL retrieved.

How to retrieve the production URL

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