🦙
Frameworks
Use Hanzo AI with LlamaIndex
Use LlamaIndex with Hanzo AI to build powerful RAG applications, data agents, and query pipelines. Drop in Hanzo as your LLM provider with zero friction.
Base URL: https://api.hanzo.ai/v1
API Key: Get yours at hanzo.ai/signup · Fully OpenAI-compatible · 390+ models available
🦙
Created by LlamaIndex
License: MIT · View source on GitHub →
Hanzo AI is OpenAI-compatible, so existing LlamaIndex code works with zero refactoring. We deeply appreciate the LlamaIndex team for building and maintaining this open-source project.
Basic setup
python
pip install llama-index llama-index-llms-openai
from llama_index.llms.openai import OpenAI
from llama_index.core import Settings
Settings.llm = OpenAI(
model="zen4-pro",
api_key="your-hanzo-api-key",
api_base="https://api.hanzo.ai/v1",
)RAG pipeline
python
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding
Settings.llm = OpenAI(
model="zen4-pro",
api_key="your-hanzo-api-key",
api_base="https://api.hanzo.ai/v1",
)
Settings.embed_model = OpenAIEmbedding(
api_key="your-hanzo-api-key",
api_base="https://api.hanzo.ai/v1",
)
documents = SimpleDirectoryReader("./data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What is in these docs?")Chat engine
python
chat_engine = index.as_chat_engine(
chat_mode="condense_plus_context",
verbose=True,
)
response = chat_engine.chat("Tell me more about this topic")Streaming query
python
streaming_response = query_engine.query(
"Summarize the key points",
streaming=True,
)
streaming_response.print_response_stream()Ready to get started?
Create a free account and get your API key. 100K API calls/month free forever.