New Tool Radar

AI Concepts

How to Get Embeddings From vLLM’s /v1/embeddings Endpoint

Serve an embedding model with vLLM and call its /v1/embeddings endpoint to turn text into vectors for search.

Schematic diagram with four steps: serve an embedding model, POST the text to /v1/embeddings, read the vector from the data list, then store it for search.

vLLM’s OpenAI-compatible server is not only for chat: the docs list an Embeddings API at /v1/embeddings, but it only works for embedding models. Serve an embedding model, not a chat model, and the same server hands out vectors your search code can store and compare.

Serve an embedding model and call the endpoint

Start the server with an embedding model, for example vllm serve BAAI/bge-small-en-v1.5 — replace the name with the embedding model you actually want. Then POST to http://localhost:8000/v1/embeddings with the model name and the input text. The reply carries the vector in the data list, in the same shape as OpenAI’s embeddings response.

vllm serve BAAI/bge-small-en-v1.5
curl http://localhost:8000/v1/embeddings \
  -H "Content-Type: application/json" \
  -d '{"model": "BAAI/bge-small-en-v1.5", "input": "hello world"}'

The model name in the request must match the served model exactly, or the Completions, Chat Completions and Responses APIs return a 404 NotFoundError — the same rule applies to the embeddings endpoint. A chat model served by mistake will not produce embeddings at all.

Try it: four checks

Check What you should see If you do not see it
Embedding model served vllm serve starts with the embedding model Check the model is an embedding model, not a chat model
Endpoint answers POST /v1/embeddings returns a data list Check the port and the model name
Vector present The reply has an embedding array of numbers Check the input field name is input
Name matches The model name matches the served model A wrong name returns a 404

Expected result. We checked the vLLM OpenAI-Compatible Server docs, which list the Embeddings API at /v1/embeddings as applicable only to embedding models, and the 404 NotFoundError rule for unknown models. We did not run vLLM on this machine.

Limits

This guide covers the embeddings endpoint only. Which embedding models vLLM supports, and their vector sizes, are separate choices. We did not test any call ourselves.

Sources

See all