Inference

Generate Embeddings

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):

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):

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):

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

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

Example Response:

{
  "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
post/api/v3/inference/embeddings

Request

  • Base URL
    https://api.nugen.in
  • Auth
    HTTP bearer

Request body

modelstring 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.

dimensionsinteger nullable

(Applicable for only Resizable Matryoshka Embedding models) The number of dimensions the resulting output embeddings should have.

Example request

{
  "model": "model_01kmqm4nrn9fw6r"
}

Response

Vector embeddings

idstring nullable required

A unique identifier of the response.

modelstring nullable required

The name of the model used to generate the embedding.

creatednumber nullable required

The Unix time in seconds when the response was generated.

object'embedding' nullable

The object type, which is always 'embedding'.

Example response

{
  "created": 1623645497,
  "data": [
    {
      "embedding": [
        0.007897645,
        -0.006754357,
        0.007654689
      ],
      "index": 0
    }
  ],
  "id": "nugen-1234",
  "model": "model_01kmqm4nrn9fw6r",
  "object": "embedding",
  "usage": {
    "total_tokens": 25
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.