VoyageAI Embedder
Generate VoyageAI retrieval embeddings with explicit document and query input types.
VoyageAIEmbedder defaults to voyage-2 with 1024 dimensions.
from agno.knowledge.embedder.voyageai import VoyageAIEmbedder
document_embedder = VoyageAIEmbedder(
request_params={"input_type": "document"},
)
query_embedder = VoyageAIEmbedder(
request_params={"input_type": "query"},
)
document_vector = document_embedder.get_embedding(
"The quick brown fox jumps over the lazy dog."
)
query_vector = query_embedder.get_embedding("Which animal jumps?")
print(len(document_vector), len(query_vector))VoyageAIEmbedder applies one request_params dictionary to every call. A single instance used by a vector database therefore applies the same input_type to document insertion and query search. VoyageAI retrieval models distinguish document from query inputs.
For a nondefault vector size, first choose a model that supports configurable output dimensions, such as the supported Voyage 3.5 family listed in the embedding API documentation. Set dimensions and request_params={"output_dimension": ...} to the same supported value. The default voyage-2 example above does not support this option; Agno forwards the parameter and does not resize vectors itself.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateExport the API key
export VOYAGE_API_KEY=your_voyage_api_key_hereInstall dependencies
uv pip install -U agno voyageaiRun the example
python voyageai_embedder.py