EdenAITextEmbedder
Embed a query string using Eden AI's multi-provider embedding API. Use this component in query pipelines to transform user queries into vectors for embedding-based retrieval.
Key Features
- Routes embedding requests through Eden AI to multiple providers—including OpenAI, Mistral, Cohere, and Google—using a single API key.
- Uses Eden AI's
provider/modelnaming convention, for exampleopenai/text-embedding-3-smallormistral/mistral-embed. - Outputs a float vector embedding suitable for use with embedding retrievers.
- Supports EU data residency through Eden AI's infrastructure.
- The model must match the one used in the corresponding
EdenAIDocumentEmbedderin the indexing pipeline.
Configuration
- Drag the
EdenAITextEmbeddercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Create a secret with your Eden AI API key. Use
EDENAI_API_KEYas the secret key. For instructions, see Create Secrets. Get your API key from Eden AI. - Set the model field to the same embedding model you used for indexing, in
provider/modelformat, for exampleopenai/text-embedding-3-small.
- Create a secret with your Eden AI API key. Use
- Go to the Advanced tab to configure
timeoutandmax_retries.
Connections
EdenAITextEmbedder receives the user query as a text string through its text input, typically from the Input component. It outputs a float vector through its embedding output, which you connect to an embedding retriever such as OpenSearchEmbeddingRetriever.
Source Code
To check this component's source code, open text_embedder.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
EdenAITextEmbedder:
type: haystack_integrations.components.embedders.edenai.text_embedder.EdenAITextEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- EDENAI_API_KEY
strict: false
model: openai/text-embedding-3-small
api_base_url: https://api.edenai.run/v3
Using the Component in a Pipeline
This example shows a query pipeline with EdenAITextEmbedder that embeds the user query and sends it to OpenSearchEmbeddingRetriever to find matching documents.
# haystack-pipeline
components:
EdenAITextEmbedder:
type: haystack_integrations.components.embedders.edenai.text_embedder.EdenAITextEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- EDENAI_API_KEY
strict: false
model: openai/text-embedding-3-small
api_base_url: https://api.edenai.run/v3
prefix: ""
suffix: ""
OpenSearchEmbeddingRetriever:
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
filters:
top_k: 10
filter_policy: replace
custom_query:
raise_on_failure: true
efficient_filtering: true
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: Standard-Index-English
max_chunk_bytes: 104857600
embedding_dim: 1536
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
connections:
- sender: EdenAITextEmbedder.embedding
receiver: OpenSearchEmbeddingRetriever.query_embedding
max_runs_per_component: 100
metadata: {}
inputs:
query:
- EdenAITextEmbedder.text
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
text | str | The text to embed. |
Outputs
| Parameter | Type | Description |
|---|---|---|
embedding | List[float] | The embedding of the input text. |
meta | Dict[str, Any] | Metadata about the request, including model name and usage statistics. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Secret | Secret.from_env_var('EDENAI_API_KEY') | The Eden AI API key. |
model | str | openai/text-embedding-3-small | The Eden AI embedding model in provider/model format. For a full list, see the Eden AI models catalog. |
api_base_url | Optional[str] | https://api.edenai.run/v3 | The Eden AI API base URL. |
prefix | str | "" | A string to add to the beginning of the text. |
suffix | str | "" | A string to add to the end of the text. |
timeout | Optional[float] | None | Timeout for API calls in seconds. Defaults to the OPENAI_TIMEOUT environment variable or 30 seconds. |
max_retries | Optional[int] | None | Maximum number of retries after an internal error. Defaults to the OPENAI_MAX_RETRIES environment variable or 5. |
http_client_kwargs | Optional[Dict[str, Any]] | None | Keyword arguments for a custom httpx.Client or httpx.AsyncClient. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Description |
|---|---|---|
text | str | The text to embed. |
Related Information
Was this page helpful?