Skip to main content

Create Embeddings

Creates an embedding vector representing the input text.

Request Body

string
required
ID of the embedding model to use. Must be an embedding model available in Jan.To use an embedding model, ensure it has "embedding": true in its settings.Examples: nomic-embed-text, sentence-transformers
string | array
required
Input text to embed. Can be a single string or an array of strings.When providing an array, each string will be embedded separately and returned in the same order.Example:
Or:
string
default:"float"
The format to return the embeddings in.Currently only "float" is supported, which returns embeddings as arrays of floating-point numbers.

Response

string
Always "list".
string
The model used for generating embeddings.
array
Array of embedding objects, one for each input string.Each object contains:
  • object (string): Always "embedding"
  • embedding (array): The embedding vector as an array of floats
  • index (number): The index of this embedding in the input array
object
Token usage information.
  • prompt_tokens (number): Number of tokens in the input
  • total_tokens (number): Total tokens processed (same as prompt_tokens for embeddings)

Example Response (Single Input)

Example Response (Multiple Inputs)

Batch Processing

Jan automatically batches large embedding requests for optimal performance.

Request with Multiple Inputs

cURL

Batch Size

Jan processes embeddings in batches for efficiency. The default batch size is 512 tokens (configurable via ubatch_size in model settings). Large requests are automatically split into batches and processed sequentially.

Use Cases

Generate embeddings for documents and queries to find semantically similar content:
Python

Clustering

Group similar texts together using embedding vectors:
Python

Text Classification

Use embeddings as features for classification tasks:
Python

Embedding Models

Jan supports various embedding models. To use a model for embeddings:
  1. The model must have "embedding": true in its settings
  2. The model architecture must be compatible (e.g., BERT, Nomic-BERT)
  • nomic-embed-text: High-quality text embeddings with 768 dimensions
  • sentence-transformers: General-purpose sentence embeddings
  • all-MiniLM-L6-v2: Lightweight and fast, 384 dimensions

Model Auto-Loading

If an embedding model is not loaded when you make a request, Jan will:
  1. Automatically load the model in embedding mode
  2. Process your request
  3. Keep the model loaded for subsequent requests
If the endpoint returns a 501 status (not available), Jan will reload the model with embedding support enabled.

Embedding Dimensions

Embedding dimensions vary by model:
  • nomic-embed-text: 768 dimensions
  • all-MiniLM-L6-v2: 384 dimensions
  • sentence-transformers: Varies by variant (typically 384-1024)
Higher dimensions generally provide more detailed representations but require more storage and computation.

Error Handling

Model Not Available

If you request an embedding from a non-embedding model:
Status: 400 Bad Request

Embedding Endpoint Not Available

If the model doesn’t have embedding support enabled:
Status: 501 Not Implemented Jan will automatically reload the model with embedding support and retry.

Input Too Long

If input exceeds the model’s maximum token limit:
Status: 400 Bad Request

Performance Tips

Batch Requests

Process multiple texts in a single request for better performance:

Keep Model Loaded

Embedding models stay loaded in memory for subsequent requests. Avoid unloading between requests to maintain performance.

GPU Acceleration

Enable GPU acceleration by setting ngl (number of GPU layers) in model settings for faster embedding generation.