EdenAIChatGenerator
Generate chat responses using 500+ AI models from multiple providers through the Eden AI unified API.
Key Features
- Connects to Eden AI's OpenAI-compatible endpoint, giving access to models from OpenAI, Anthropic, Mistral, Google, Cohere, and more.
- Selects models using Eden AI's
provider/modelnaming format (for example,openai/gpt-4o-mini,anthropic/claude-sonnet-4-5). - Accepts and returns messages in
ChatMessageformat. - Supports streaming responses through a configurable callback.
- Supports tool calling and strict schema adherence.
- Supports provider fallback and EU data residency through Eden AI's platform features.
Configuration
- Drag the
EdenAIChatGeneratorcomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set the
modelusing Eden AI'sprovider/modelformat, for exampleopenai/gpt-4o-miniormistral/mistral-large-latest. For a full list, see the Eden AI models catalog. - Create a secret with your Eden AI API key and set it as
api_key. UseEDENAI_API_KEYas the environment variable name. For instructions, see Create Secrets.
- Set the
- Go to the Advanced tab to configure
generation_kwargs,timeout, andmax_retries.
Connections
EdenAIChatGenerator receives a list of ChatMessage objects, typically from PromptBuilder or ChatPromptBuilder. It outputs a list of reply ChatMessage objects you can connect to AnswerBuilder or other downstream components.
Source Code
To check this component's source code, open chat_generator.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
EdenAIChatGenerator:
type: haystack_integrations.components.generators.edenai.chat.chat_generator.EdenAIChatGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- EDENAI_API_KEY
strict: false
model: openai/gpt-4o-mini
generation_kwargs:
max_tokens: 1024
Using the Component in a Pipeline
# haystack-pipeline
components:
prompt_builder:
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
init_parameters:
required_variables: "*"
template:
- role: user
content: "Answer the following question: {{ question }}"
llm:
type: haystack_integrations.components.generators.edenai.chat.chat_generator.EdenAIChatGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- EDENAI_API_KEY
strict: false
model: openai/gpt-4o-mini
generation_kwargs:
max_tokens: 1024
answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm
connections:
- sender: prompt_builder.prompt
receiver: llm.messages
- sender: llm.replies
receiver: answer_builder.replies
max_runs_per_component: 100
metadata: {}
inputs:
query:
- answer_builder.query
- prompt_builder.question
outputs:
answers: answer_builder.answers
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
messages | List[ChatMessage] | A list of chat messages representing the conversation so far. |
Outputs
| Parameter | Type | Description |
|---|---|---|
replies | List[ChatMessage] | A list of generated reply messages from the model. |
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/gpt-4o-mini | The model to use in Eden AI's provider/model format. For example, openai/gpt-4o-mini, anthropic/claude-sonnet-4-5, or mistral/mistral-large-latest. |
streaming_callback | Optional[Callable] | None | A callback function for streaming responses. |
generation_kwargs | Optional[Dict[str, Any]] | None | Additional generation parameters such as max_tokens, temperature, and top_p. Eden AI-specific parameters (for example, a fallback model) are forwarded as-is. |
timeout | Optional[int] | None | Request timeout in seconds. |
max_retries | Optional[int] | None | Maximum number of retries on API errors. |
tools | Optional[ToolsType] | None | A list of tools the model can use. |
tools_strict | bool | False | If True, enable strict schema adherence for tool calls. |
http_client_kwargs | Optional[Dict[str, Any]] | None | Additional keyword arguments passed to the underlying HTTP client. |
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 | Default | Description |
|---|---|---|---|
messages | List[ChatMessage] | A list of chat messages representing the conversation. | |
streaming_callback | Optional[Callable] | None | A callback function to override the init-time streaming callback. |
generation_kwargs | Optional[Dict[str, Any]] | None | Additional generation parameters to override init-time values. |
tools | Optional[List[Tool]] | None | Tools to make available to the model. |
Related Information
Was this page helpful?