Implementation:CrewAIInc CrewAI Embedder Config
Appearance
Metadata
| Field | Value |
|---|---|
| Implementation Name | Embedder Config |
| Workflow | Knowledge_RAG_Pipeline |
| Category | Vector Representation |
| Repository | crewAIInc/crewAI |
| Implements | Principle:CrewAIInc_CrewAI_Embedding_Configuration |
Overview
Concrete type alias and provider specifications for configuring embedding models across 18+ providers provided by the CrewAI RAG subsystem. The EmbedderConfig type alias unifies provider-specific TypedDicts, base provider instances, and provider classes into a single configurable type.
Source Reference
| File | Lines |
|---|---|
| src/crewai/rag/embeddings/types.py | L32-76 |
Signature
EmbedderConfig: TypeAlias = (
ProviderSpec
| BaseEmbeddingsProvider[Any]
| type[BaseEmbeddingsProvider[Any]]
)
Where ProviderSpec is a union of 18 provider-specific TypedDicts, each following the pattern:
class OpenAIProviderSpec(TypedDict):
provider: Literal["openai"]
config: dict[str, Any]
class OllamaProviderSpec(TypedDict):
provider: Literal["ollama"]
config: dict[str, Any]
# ... and so on for each provider
Allowed embedding providers:
AllowedEmbeddingProviders = Literal[
"azure",
"amazon-bedrock",
"cohere",
"custom",
"google-generativeai",
"google-vertex",
"huggingface",
"instructor",
"jina",
"ollama",
"onnx",
"openai",
"openclip",
"roboflow",
"sentence-transformer",
"text2vec",
"voyageai",
"watsonx",
]
Import
from crewai.rag.embeddings.types import EmbedderConfig
I/O Contract
| Direction | Type | Description |
|---|---|---|
| Input | dict with provider and config keys |
Provider specification dictionary matching one of the 18 provider TypedDicts |
| Input (alt) | BaseEmbeddingsProvider instance |
A pre-configured embedding provider instance |
| Input (alt) | type[BaseEmbeddingsProvider] |
An embedding provider class (instantiated by the framework) |
| Output | EmbedderConfig |
Configuration value accepted by Knowledge, Crew, Agent, or KnowledgeStorage |
Provider Configuration Details
Each provider accepts a config dictionary with provider-specific keys:
| Provider | Common Config Keys |
|---|---|
openai |
model, api_key, api_base
|
ollama |
model, url
|
cohere |
model, api_key
|
huggingface |
model, api_key
|
google-generativeai |
model, api_key
|
azure |
model, api_key, api_base, api_version
|
amazon-bedrock |
model, region_name
|
sentence-transformer |
model
|
jina |
model, api_key
|
voyageai |
model, api_key
|
Code Examples
OpenAI Embedder Configuration
from crewai.rag.embeddings.types import EmbedderConfig
openai_embedder: EmbedderConfig = {
"provider": "openai",
"config": {
"model": "text-embedding-3-small",
"api_key": "sk-...",
},
}
Ollama Local Embedder Configuration
ollama_embedder: EmbedderConfig = {
"provider": "ollama",
"config": {
"model": "nomic-embed-text",
"url": "http://localhost:11434",
},
}
Using Embedder Config with a Crew
from crewai import Crew
crew = Crew(
agents=[...],
tasks=[...],
knowledge_sources=[...],
embedder={
"provider": "openai",
"config": {
"model": "text-embedding-3-small",
},
},
)
Using a Provider Instance
from crewai.rag.embeddings.types import EmbedderConfig
# You can also pass a pre-configured provider instance
# instead of a dictionary specification
custom_provider = MyCustomEmbeddingsProvider(model="my-model")
embedder_config: EmbedderConfig = custom_provider
Related Pages
- Principle:CrewAIInc_CrewAI_Embedding_Configuration -- The principle this implements
- Implementation:CrewAIInc_CrewAI_Knowledge_Source_Classes -- Source classes that produce chunks for embedding
- Implementation:CrewAIInc_CrewAI_Knowledge_Constructor -- Knowledge class that accepts embedder config
- Implementation:CrewAIInc_CrewAI_Knowledge_Storage_Search -- Storage that uses embedder for indexing and search
- Environment:CrewAIInc_CrewAI_Optional_Provider_Dependencies
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment