Skip to main content
Generate embeddings from a model for one or more input strings. This endpoint supports batch embedding generation and optional dimensionality reduction.

Request

Endpoint

POST /api/embed

Request Body

model
string
required
Model name to use for embedding generation (e.g., nomic-embed-text, mxbai-embed-large)
input
string | array
required
Text input to generate embeddings for. Can be a single string or array of strings.
keep_alive
string | number
default:"5m"
Duration to keep model loaded in memory (e.g., "5m", "1h", -1 for indefinite)
truncate
boolean
default:"true"
Truncate input to fit the model’s maximum sequence length
dimensions
integer
Truncate output embeddings to specified dimensions (must be less than model’s default)
options
object
Model-specific options for embedding generation

Response

Response Fields

model
string
The model used for embedding generation
embeddings
array
Array of embedding vectors. Each embedding is an array of floating-point numbers.
total_duration
integer
Total time in nanoseconds
load_duration
integer
Time spent loading the model in nanoseconds
prompt_eval_count
integer
Total number of tokens processed across all inputs

Examples

Single String Embedding

curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": "The quick brown fox jumps over the lazy dog"
}'

Example Response

{
  "model": "nomic-embed-text",
  "embeddings": [
    [
      0.5670403838157654,
      0.009260174818336964,
      -0.4829583466053009,
      ...
    ]
  ],
  "total_duration": 123456789,
  "load_duration": 12345678,
  "prompt_eval_count": 10
}

Batch Embedding

curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": [
    "The sky is blue",
    "The grass is green",
    "The sun is yellow"
  ]
}'

Dimensionality Reduction

curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": "Sample text",
  "dimensions": 128
}'

Truncation Control

curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": "Very long text that exceeds model context...",
  "truncate": false
}'

Error Responses

error
string
Description of the error

Common Errors

  • 400 Bad Request: Invalid input type or empty input
  • 404 Not Found: Model not found
  • 500 Internal Server Error: Embedding generation error
Embeddings are automatically normalized to unit length. If you specify dimensions, the output is truncated and then re-normalized.
To preload a model without generating embeddings, send an empty array or empty string as input.