Skip to main content
Embedding is part of the Ingest workflow. It turns chunks into vectors so similar meaning lands close together during retrieval. Use this page to understand the embedding stage. Use the interface-specific pages when you need exact parameters, flags, request fields, or response shapes.
Use the same embedding provider and model for indexing and querying. Vectors from different models are not comparable.

Source and output

Embedding takes chunk dictionaries from Chunking and returns the same chunks with an added embedding vector.
Example embedded result:
The SDK and REST API return embedded chunks in memory. The CLI writes embedded.json to --output-dir. Vector database persistence happens in Storing, not embedding.

What gets embedded

Each input chunk must be a dictionary with non-empty text. If the chunk also has embed_text, Ragrails sends embed_text to the embedding model and keeps text for citations and display.
embed_text is created by the chunking stage from the title, heading path, description, and visible text. This improves semantic retrieval without changing the text you show users later.
If embed_text is missing, Ragrails embeds the chunk text field.

Providers

Ragrails ships with Voyage embeddings and a registry for custom embedders. Voyage requires VOYAGE_API_KEY in the environment that runs embedding.

Input type

Embedding providers may optimize vectors differently for indexed documents and user queries. Ragrails uses input_type="document" by default for embed() because embedding is an indexing step. Retrieval and chat create query embeddings with input_type="query" for you. You normally only set input_type manually when constructing an embedder or using /v1/embed for a non-indexing workflow.
Do not index documents with input_type="query" or query with input_type="document" unless you intentionally know the provider behavior. Mismatching input types can degrade retrieval quality.

Batching

batch_size controls how many chunks are sent to the embedding stage per request batch. batch_size must be an integer greater than 0. If one provider batch fails, each chunk in that batch gets a retryable embed error and other valid batches can still succeed.

Output shape

The id is resolved from the chunk id, then metadata.id, then metadata.chunk_id. The source is resolved from the chunk source, then metadata.source.

Ingest pipeline

High-level ingestion embeds after chunking and before storing. Pass embedding options through the embedding object.

Possible errors

Interface validation errors raise immediately in SDK and REST. Chunk validation and provider failures are returned in the result errors list when processing can continue. See Errors for the shared shapes.

Next steps

  • Use Storing to write embedded chunks to a vector database.
  • Use Retrieval to embed queries and search the stored vectors.
  • Use Ingest to run extraction, chunking, embedding, and storage together.