Cohere Embedder

Generate Cohere embeddings with an explicit model, input type, and vector dimension.

CohereEmbedder defaults to embed-english-v3.0 and reads CO_API_KEY through the Cohere client.

from agno.knowledge.embedder.cohere import CohereEmbedder

document_embedder = CohereEmbedder(
    id="embed-english-v3.0",
    dimensions=1024,
    input_type="search_document",
)
query_embedder = CohereEmbedder(
    id="embed-english-v3.0",
    dimensions=1024,
    input_type="search_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(f"Document dimensions: {len(document_vector)}")
print(f"Query dimensions: {len(query_vector)}")

CohereEmbedder currently applies one configured input_type to every call. A single instance used by a vector database therefore applies the same input type to document insertion and query search. Cohere retrieval models distinguish search_document from search_query.

Set dimensions=1024 with embed-english-v3.0 so the vector database schema matches the returned vectors. This field configures Agno's expected vector width. It does not change the model's fixed 1024-dimensional output.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Export the API key

export CO_API_KEY=your_cohere_api_key_here

Install dependencies

uv pip install -U agno cohere

Run the example

python cohere_embedder.py

Developer Resources