LlamaIndex Embeddings Cohere
raw JSON → 0.8.0 verified Fri May 01 auth: no python
LlamaIndex integration for Cohere embedding models. Current version 0.8.0, requires Python >=3.10 and <4.0. Released as part of the llama-index plugin ecosystem; version bumps may follow llama-index core releases.
pip install llama-index-embeddings-cohere Common errors
error ImportError: cannot import name 'CohereEmbedding' from 'llama_index' ↓
cause Incorrect import path; trying to import directly from the top-level `llama_index` package.
fix
Use
from llama_index.embeddings.cohere import CohereEmbedding. error cohere.core.api_error.ApiError: status_code: 400, body: {'message': 'input_type is required'} ↓
cause Missing `input_type` parameter when using Cohere embedding models that require it (e.g., embed-english-v3.0).
fix
Pass
input_type to the embedding call or during initialization. error TypeError: __init__() got an unexpected keyword argument 'embed_batch_size' ↓
cause The `embed_batch_size` parameter was removed in newer versions of this library.
fix
Remove
embed_batch_size from the constructor arguments. Warnings
breaking Version 0.8.0 changed import path from `llama_index.embeddings.cohere` (previously may have been `llama_index.embeddings.cohere.base`). Ensure correct import. ↓
fix Use `from llama_index.embeddings.cohere import CohereEmbedding`.
deprecated The `embed_batch_size` parameter was removed; batching is now handled automatically. ↓
fix Remove `embed_batch_size` when constructing CohereEmbedding.
gotcha Cohere requires `input_type` parameter (e.g., 'search_query', 'search_document', 'classification'). Omitting it may cause errors from the API. ↓
fix Always specify `input_type` when calling `get_text_embedding` or during initialization.
Imports
- CohereEmbedding
from llama_index.embeddings.cohere import CohereEmbedding - CohereEmbedding wrong
from llama_index import CohereEmbeddingcorrectfrom llama_index.embeddings.cohere import CohereEmbedding
Quickstart
import os
from llama_index.embeddings.cohere import CohereEmbedding
embed_model = CohereEmbedding(
api_key=os.environ.get("COHERE_API_KEY", ""),
model_name="embed-english-v3.0",
input_type="search_query",
)
print(embed_model.get_text_embedding("Hello world!")[:5])