-
Notifications
You must be signed in to change notification settings - Fork 1
docs: add Haystack (deepset) integration page #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| --- | ||
| title: "Haystack" | ||
| icon: "/integration-logo/haystack-icondoc.svg" | ||
| description: "Use Eden AI with Haystack (deepset) to build LLM and RAG pipelines on 500+ AI models through one EU-hosted API key." | ||
| --- | ||
|
|
||
| import { TechArticleSchema } from "/snippets/TechArticleSchema.mdx"; | ||
|
|
||
| <TechArticleSchema | ||
| title={"Haystack"} | ||
| description={"Use Eden AI with Haystack (deepset) to build LLM and RAG pipelines on 500+ AI models through one EU-hosted API key."} | ||
| path="v3/integrations/haystack" | ||
| articleSection="AI Frameworks" | ||
| about={"LLM Framework Integration"} | ||
| proficiencyLevel="Intermediate" | ||
| keywords={["Eden AI", "AI API", "Haystack", "deepset", "RAG", "Python"]} | ||
| datePublished="2026-07-21T00:00:00Z" | ||
| dateModified="2026-07-21T00:00:00Z" | ||
| /> | ||
|
|
||
| Use Eden AI with Haystack (deepset) to build LLM and RAG pipelines on 500+ AI models through one EU-hosted API key. | ||
|
|
||
| ## Overview | ||
|
|
||
| [Haystack](https://haystack.deepset.ai/) is deepset's open-source Python framework for building production LLM applications, RAG pipelines and agents. **Eden AI ships as an official Haystack integration** (the `edenai-haystack` package), so your pipelines reach models from OpenAI, Anthropic, Google, Mistral and 500+ more behind one key, with EU-based, GDPR-aligned inference. | ||
|
|
||
| The integration provides three components: | ||
|
|
||
| - `EdenAIChatGenerator` for chat completion | ||
| - `EdenAITextEmbedder` to embed a query string | ||
| - `EdenAIDocumentEmbedder` to embed documents for indexing | ||
|
|
||
| Models use Eden AI's `provider/model` naming convention, for example `anthropic/claude-sonnet-4-5` or `mistral/mistral-large-latest`. | ||
|
|
||
| ## Installation | ||
|
|
||
| <CodeGroup> | ||
| ```bash pip | ||
| pip install edenai-haystack | ||
| ``` | ||
|
|
||
| ```bash uv | ||
| uv add edenai-haystack | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Set your key, then generate a chat response with the `EdenAIChatGenerator`: | ||
|
|
||
| <CodeGroup> | ||
| ```bash .env | ||
| EDENAI_API_KEY=your_api_key_here | ||
| ``` | ||
|
|
||
| {/* skip-test */} | ||
| ```python Python | ||
| from haystack.dataclasses import ChatMessage | ||
| from haystack_integrations.components.generators.edenai import EdenAIChatGenerator | ||
|
|
||
| generator = EdenAIChatGenerator(model="mistral/mistral-large-latest") | ||
|
|
||
| response = generator.run([ChatMessage.from_user("What is Eden AI?")]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Use keyword arguments for Haystack 2.x components enforce or strongly expect keyword arguments for their
📍 Affects 1 file
🤖 Prompt for AI Agents |
||
| print(response["replies"][0].text) | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| The generator reads your key from the `EDENAI_API_KEY` environment variable by default. | ||
|
|
||
| ## Switching models | ||
|
|
||
| Change providers by changing the `model` string. Every Eden AI model is reachable the same way: | ||
|
|
||
| <CodeGroup> | ||
| {/* skip-test */} | ||
| ```python Python | ||
| from haystack.dataclasses import ChatMessage | ||
| from haystack_integrations.components.generators.edenai import EdenAIChatGenerator | ||
|
|
||
| messages = [ChatMessage.from_user("Write a haiku about the sea.")] | ||
|
|
||
| for model in [ | ||
| "openai/gpt-4o-mini", | ||
| "anthropic/claude-sonnet-4-5", | ||
| "mistral/mistral-large-latest", | ||
| ]: | ||
| generator = EdenAIChatGenerator(model=model) | ||
| print(model, "->", generator.run(messages)["replies"][0].text) | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Streaming | ||
|
|
||
| Pass a `streaming_callback` to stream tokens as they are generated: | ||
|
|
||
| <CodeGroup> | ||
| {/* skip-test */} | ||
| ```python Python | ||
| from haystack.components.generators.utils import print_streaming_chunk | ||
| from haystack.dataclasses import ChatMessage | ||
| from haystack_integrations.components.generators.edenai import EdenAIChatGenerator | ||
|
|
||
| generator = EdenAIChatGenerator( | ||
| model="mistral/mistral-large-latest", | ||
| streaming_callback=print_streaming_chunk, | ||
| ) | ||
| generator.run([ChatMessage.from_user("Count from one to five.")]) | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Embeddings and RAG | ||
|
|
||
| Use `EdenAITextEmbedder` to embed a query and `EdenAIDocumentEmbedder` to embed documents, so you can build a fully sovereign RAG stack (retrieval and generation) on EU-hosted models: | ||
|
|
||
| <CodeGroup> | ||
| {/* skip-test */} | ||
| ```python Python | ||
| from haystack import Document | ||
| from haystack.document_stores.in_memory import InMemoryDocumentStore | ||
| from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever | ||
| from haystack_integrations.components.embedders.edenai import ( | ||
| EdenAIDocumentEmbedder, | ||
| EdenAITextEmbedder, | ||
| ) | ||
|
|
||
| document_store = InMemoryDocumentStore(embedding_similarity_function="cosine") | ||
|
|
||
| # Index documents with their embeddings | ||
| documents = [Document(content="Eden AI is a unified API for 500+ AI models.")] | ||
| doc_embedder = EdenAIDocumentEmbedder(model="openai/text-embedding-3-small") | ||
| document_store.write_documents(doc_embedder.run(documents)["documents"]) | ||
|
|
||
| # Embed the query and retrieve | ||
| text_embedder = EdenAITextEmbedder(model="openai/text-embedding-3-small") | ||
| retriever = InMemoryEmbeddingRetriever(document_store=document_store) | ||
| query_embedding = text_embedder.run("What is Eden AI?")["embedding"] | ||
| print(retriever.run(query_embedding=query_embedding)["documents"]) | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Available Models | ||
|
|
||
| Use the `provider/model` format for any Eden AI model: | ||
|
|
||
| **Chat** | ||
| - `openai/gpt-4o-mini` | ||
| - `anthropic/claude-sonnet-4-5` | ||
| - `mistral/mistral-large-latest` | ||
| - `google/gemini-2.5-flash` | ||
|
|
||
| **Embeddings** | ||
| - `openai/text-embedding-3-small` | ||
| - `mistral/mistral-embed` | ||
|
|
||
| Browse the full list in the [Eden AI models catalog](https://www.edenai.co/models). | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| <CodeGroup> | ||
| ```bash .env | ||
| EDENAI_API_KEY=your_api_key_here | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Next Steps | ||
|
|
||
| - [Chat Completions](/v3/llms/chat-completions) - Core LLM endpoint | ||
| - [List LLM Models](/v3/llms/listing-models) - Browse available providers and models | ||
| - [aisuite](/v3/integrations/aisuite) - Another unified LLM interface | ||
| - [LangChain](/v3/integrations/langchain) - Build LLM apps with LangChain | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use standard token placeholder.
Both snippets use
your_api_key_here, but the coding guidelines require distinguishing token types by usingapi_token(for production) orsandbox_api_token(for testing) in examples without real provider calls. Please update the placeholder toapi_tokento maintain consistency across the documentation.v3/integrations/haystack.mdx#L53-L53: replaceyour_api_key_herewithapi_tokenv3/integrations/haystack.mdx#L161-L161: replaceyour_api_key_herewithapi_token📍 Affects 1 file
v3/integrations/haystack.mdx#L53-L53(this comment)v3/integrations/haystack.mdx#L161-L161🤖 Prompt for AI Agents
Source: Coding guidelines