🌾
Frameworks
Use Hanzo AI with Haystack
Build production-ready NLP pipelines and RAG systems with Haystack using Hanzo AI as the LLM provider. Haystack's OpenAI integration works seamlessly.
Base URL: https://api.hanzo.ai/v1
API Key: Get yours at hanzo.ai/signup · Fully OpenAI-compatible · 390+ models available
🌾
Created by deepset.ai
License: Apache-2.0 · View source on GitHub →
Hanzo AI is OpenAI-compatible, so existing Haystack code works with zero refactoring. We deeply appreciate the deepset.ai team for building and maintaining this open-source project.
Haystack + Hanzo
python
pip install haystack-ai
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret
generator = OpenAIChatGenerator(
model="zen4-pro",
api_key=Secret.from_token("your-hanzo-api-key"),
api_base_url="https://api.hanzo.ai/v1",
)
messages = [ChatMessage.from_user("What is RAG?")]
result = generator.run(messages=messages)RAG pipeline
python
from haystack import Pipeline
from haystack.components.builders import PromptBuilder
from haystack.components.generators.chat import OpenAIChatGenerator
prompt_template = """
Context: {% for doc in documents %}{{ doc.content }}{% endfor %}
Question: {{ question }}
Answer:
"""
pipeline = Pipeline()
pipeline.add_component("prompt", PromptBuilder(template=prompt_template))
pipeline.add_component("llm", OpenAIChatGenerator(
model="zen4-pro",
api_key=Secret.from_token("your-hanzo-api-key"),
api_base_url="https://api.hanzo.ai/v1",
))Embeddings
python
from haystack.components.embedders import OpenAITextEmbedder
embedder = OpenAITextEmbedder(
model="openai/text-embedding-3-large",
api_key=Secret.from_token("your-hanzo-api-key"),
api_base_url="https://api.hanzo.ai/v1",
)Install
bash
pip install haystack-ai
export HANZO_API_KEY="your-hanzo-api-key"Ready to get started?
Create a free account and get your API key. 100K API calls/month free forever.