⛓️
Frameworks
Use Hanzo AI with LangChain
Integrate LangChain with Hanzo AI to build chains, agents, and RAG pipelines using any of our 390+ models. Hanzo is OpenAI-compatible so ChatOpenAI just works.
Base URL: https://api.hanzo.ai/v1
API Key: Get yours at hanzo.ai/signup · Fully OpenAI-compatible · 390+ models available
⛓️
Created by LangChain AI
License: MIT · View source on GitHub →
Hanzo AI is OpenAI-compatible, so existing LangChain code works with zero refactoring. We deeply appreciate the LangChain AI team for building and maintaining this open-source project.
LangChain Python
python
pip install langchain langchain-openai
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="zen4-pro",
openai_api_key="your-hanzo-api-key",
openai_api_base="https://api.hanzo.ai/v1",
)
response = llm.invoke("What is the capital of France?")
print(response.content)Chain with prompt
python
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
prompt = ChatPromptTemplate.from_template("Summarize: {text}")
llm = ChatOpenAI(
model="openai/gpt-4.1-mini",
openai_api_key="your-hanzo-api-key",
openai_api_base="https://api.hanzo.ai/v1",
)
chain = prompt | llm
result = chain.invoke({"text": "LangChain is a framework..."})LangChain TypeScript
typescript
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
modelName: "zen4-pro",
openAIApiKey: process.env.HANZO_API_KEY,
configuration: {
baseURL: "https://api.hanzo.ai/v1",
},
});
const response = await model.invoke("Hello!");RAG with Hanzo
python
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
openai_api_key="your-hanzo-api-key",
openai_api_base="https://api.hanzo.ai/v1",
model="openai/text-embedding-3-large",
)
llm = ChatOpenAI(
model="zen4-pro",
openai_api_key="your-hanzo-api-key",
openai_api_base="https://api.hanzo.ai/v1",
)Ready to get started?
Create a free account and get your API key. 100K API calls/month free forever.