---
title: "Generate Embeddings"
method: POST
path: "/api/v3/inference/embeddings"
tags: ["Inference"]
---

# Generate Embeddings

`POST /api/v3/inference/embeddings`

## Request

- Base URL: `https://api.nugen.in`
- URL: `https://api.nugen.in/api/v3/inference/embeddings`
- Auth: HTTP bearer

Generate dense vector embeddings for input text.


This endpoint creates numerical vector representations (embeddings) of text using specified embedding models. Embeddings are useful for semantic search, clustering, similarity comparisons, and RAG applications.


**Request Body:**

- `model`: Model ID (required). Use your aligned model id (e.g. `model_01kmqm4nrn9fw6r`)
- `input`: Text or list of texts to embed (required) - Single string or array of strings. Cannot be empty and must not exceed max input tokens for the model
- `dimensions` (optional): Number of dimensions for output embeddings (only applicable for Resizable Matryoshka Embedding models)


**Returns:**

- `id`: Unique identifier for the response
- `object`: Object type (always `embedding`)
- `data`: List of embedding objects, each containing:
  - `object`: Object type (always `embedding`)
  - `embedding`: Vector of floats representing the text (length depends on the model)
  - `index`: Position in the input array
- `model`: Model ID used for generation
- `created`: Unix timestamp (seconds) when response was generated
- `usage`: Token usage statistics containing:
  - `total_tokens`: Total number of tokens used by the request


**Example Request (Single Text):**

```json
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "text-embedding-xyz",
  "input": "The quick brown fox jumps over the lazy dog"
}
```


**Example Request (Multiple Texts):**

```json
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "input": [
    "First document for semantic search",
    "Second document for clustering",
    "Third document for similarity comparison"
  ]
}
```


**Example Request (With Dimensions):**

```json
POST /api/v3/inference/embeddings
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "input": "Sample text to embed",
  "dimensions": 512
}
```


**Example Response:**

```json
{
  "id": "embed-abc123xyz",
  "object": "embedding",
  "data": [
    {
      "object": "embedding",
      "embedding": [0.00658765, -0.008665467, -0.007653789, 0.0023, -0.0091, 0.0125],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "created": 1705329600.0,
  "usage": {
    "total_tokens": 10
  }
}
```


**Notes:**

- Input must not exceed the maximum input tokens supported by the model
- Input cannot be an empty string
- For batch processing, pass multiple texts as an array to the `input` field
- The embedding vector length varies by model - check model documentation for specifics
- Use `dimensions` parameter only with Matryoshka embedding models that support resizing

## Request body

- EmbeddingRequest: An embeddings request in the OpenAI format.
  - `input` union, required: Input text to embed, encoded as a string or a list of strings. To embed multiple inputs in a single request, pass a list of strings. The input must not exceed the max input tokens for the model, cannot be an empty string.
    - string[]
    - string
  - `model` string, required: Use your aligned model id (e.g. model_01kmqm4nrn9fw6r). The same aligned id serves chat completions, completions, embeddings and reranking. Alignment shapes the model's representation space, so aligned embeddings are recommended for domain retrieval.
  - `dimensions` integer, nullable: (Applicable for only Resizable Matryoshka Embedding models) The number of dimensions the resulting output embeddings should have.

## Response `200`

Vector embeddings

- EmbeddingResponse: Embedding vectors for the input, in the OpenAI format.
  - `id` string, nullable, required: A unique identifier of the response.
  - `data` EmbeddingObject[], nullable, required: The list of embeddings generated by the model.
    - `index` integer, nullable, required: The index of the embedding in the list of embeddings.
    - `embedding` number[], nullable, required: The embedding vector, which is a list of floats.
    - `object` 'embedding', nullable: The object type, which is always 'embedding'.
  - `model` string, nullable, required: The name of the model used to generate the embedding.
  - `created` number, nullable, required: The Unix time in seconds when the response was generated.
  - `object` 'embedding', nullable: The object type, which is always 'embedding'.
  - `usage` EmbeddingUsage, required: Token counts for an embeddings request.
    - `total_tokens` integer, required: The total number of tokens used by the request.

## Other responses

- `401`: Invalid API key
- `403`: Authorization header missing or not a Bearer token
- `422`: Validation Error

---

[API](https://skmtc.dev/nugen/apis/nugen-intelligence-api.md) - [All operations](https://skmtc.dev/nugen/apis/nugen-intelligence-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nugen/apis/nugen-intelligence-api/revisions/62baa7960a4a?raw)
