Ollama embeddings convert text into numeric vectors for search, retrieval, clustering, and RAG indexing. The endpoint is separate from chat generation because the model must support embedding output rather than conversational completion.

The api/embed request accepts one string or an array of strings and returns an embeddings array. Use the same embedding model for indexing and querying so vector lengths and semantics stay compatible.

The campaign validated the flow with all-minilm:latest after a worker pulled that small model. Remove or replace the model after validation if the host should not keep extra embedding models.

Steps to generate embeddings with the Ollama API:

  1. Pull an embedding model if it is not already installed.
    $ ollama pull all-minilm
    success

    Official Ollama docs also list embeddinggemma and qwen3-embedding as embedding model options.

  2. Send a single input string to the embed endpoint.
    $ curl -s http://localhost:11434/api/embed -d '{
      "model": "all-minilm:latest",
      "input": "Ollama embeddings test"
    }'
    {"model":"all-minilm:latest","embeddings":[[-0.016053036,-0.017273553,0.01791495,##### snipped #####]],"total_duration":62996750}

    The response is intentionally trimmed because embedding vectors are long.

  3. Send multiple strings when the application needs a batch.
    $ curl -s http://localhost:11434/api/embed -d '{
      "model": "all-minilm:latest",
      "input": ["first document", "second document"]
    }'
    {"model":"all-minilm:latest","embeddings":[[##### snipped #####],[##### snipped #####]]}
  4. Check that the response shape matches the number of inputs.
    $ python3 - <<'PY'
    import json
    payload = {"embeddings": [[0.1, 0.2], [0.3, 0.4]]}
    print(len(payload["embeddings"]))
    PY
    2

    Use the application language's JSON parser rather than string matching the response.

  5. Use a chat model error as a model-selection signal.
    $ curl -s http://localhost:11434/api/embed -d '{"model":"gpt-oss:20b","input":"test"}'
    {"error":"This server does not support embeddings. Start it with `--embeddings`"}

    Switch to an embedding-capable model before debugging vector database code.