New Tool Radar

AI Concepts

How to Get Text Embeddings from a LocalAI Embeddings Model

Install a Qwen3 embedding model in LocalAI, send text to the embeddings endpoint, and read the vector back from data[0].embedding.

Schematic diagram with three steps: install the qwen3-embedding-4b model, send text to the embeddings endpoint, then read the vector back from data[0].embedding.

An embedding is a list of numbers that stands for the meaning of a piece of text, so that similar texts get similar numbers. LocalAI supports generating embeddings for text or list of tokens, and the embedding endpoint is compatible with llama.cpp models, bert.cpp models, and sentence-transformers models available in Hugging Face. This guide installs one embedding model, sends it one sentence, and reads the vector back. It is not chat, speech, or image generation — the reply is numbers, not words.

Install an embeddings model

LocalAI provides a model gallery with pre-configured embedding models. To use a gallery model, check it is available in the gallery and use the model name directly in your API calls. The example gallery models are qwen3-embedding-4b, the Qwen3 Embedding 4B model, qwen3-embedding-8b, and qwen3-embedding-0.6b.

If you set the model up by hand instead, create a YAML config file in the models directory with the embeddings: true flag — that flag is what marks the model as an embedding model:

name: text-embedding-ada-002 # The model name used in the API
parameters:
  model: <model_file>
backend: "<backend>"
embeddings: true

For a llama.cpp embedding model the same flag applies: backend: llama-cpp with embeddings: true. The docs’ troubleshooting section says a missing embeddings: true flag is a common cause of a model returning empty or incorrect embeddings.

Send text to the embeddings endpoint

Send a POST request with the text and the model name. The docs’ gallery example uses the 4B model with 2560 dimensions:

curl http://localhost:8080/embeddings -X POST -H "Content-Type: application/json" -d '{
  "input": "My text to embed",
  "model": "qwen3-embedding-4b",
  "dimensions": 2560
}'

Send the model name in the request body. If the body has no model, LocalAI uses the configured embeddings model whose name comes first alphabetically. If no embeddings model is configured, the request returns 400 Bad Request. The Qwen3 Embedding models support user-defined output dimensions: the 0.6B model up to 1024, the 4B model up to 2560, and the 8B model up to 4096, all with a maximum context of 32k and 100+ languages.

Read the vector back

The reply follows the standard OpenAI embeddings shape, with the vector in data[0].embedding — a list of numbers, one per dimension. To count the numbers and confirm the size you asked for, pipe the reply through jq:

curl http://localhost:8080/embeddings -X POST -H "Content-Type: application/json" -d '{
  "input": "My text to embed",
  "model": "qwen3-embedding-4b",
  "dimensions": 2560
}' | jq '.data[0].embedding | length'

The count should be 2560, matching the dimensions you requested. If the model is not found, the API returns a 404 or “model not found” error, and the docs say to check that the model name in your request matches the name field in the configuration.

Try it: four checks from install to vector

Check What you should see If you do not see it
Model installed qwen3-embedding-4b available from the Model gallery Check the gallery install finished and the model name is spelled qwen3-embedding-4b
Request accepted A reply with a data[0].embedding vector and no error A 400 means no embeddings model is configured — check the model name is in the request body
Dimensions match With "dimensions": 2560, the vector length is 2560 Check the dimensions value is within 32 to 2560 for the 4B model
Shorter vector With "dimensions": 1024, the vector length is 1024 Check the request still names qwen3-embedding-4b and the dimensions field is a number

Expected result. We checked the LocalAI embeddings docs page, which gives the text-or-list-of-tokens support, the llama.cpp, bert.cpp, and sentence-transformers compatibility, the gallery models qwen3-embedding-4b, qwen3-embedding-8b, and qwen3-embedding-0.6b, the gallery example curl with input “My text to embed”, model qwen3-embedding-4b, and dimensions 2560, the manual YAML setup with embeddings: true, the no-model rule with the first alphabetical model and the 400 Bad Request, the dimensions ranges 1024 for 0.6B, 2560 for 4B, and 4096 for 8B with a 32k maximum context and 100+ languages, the standard OpenAI embeddings shape with data[0].embedding, and the troubleshooting notes on the missing embeddings: true flag and the 404 model-not-found error. We did not install LocalAI or request any embedding on this machine.

Limits

This guide covers one embedding for one piece of text only. It does not search, rank, or compare anything: using embeddings to find similar documents is a separate job that builds on the vectors you get here. Use a real embedding model such as the Qwen3 series, and make sure its configuration carries embeddings: true: the docs’ troubleshooting section says a missing flag is a common cause of a model returning empty or incorrect embeddings. The face-recognition feature produces its own 512-d vectors and is a different endpoint. We did not run any of this ourselves.

Sources

See all