# Use Hanzo AI with Vercel AI SDK — Hanzo AI

> Use the Vercel AI SDK with Hanzo AI to build streaming AI UIs, chatbots, and generative interfaces in Next.js, React, and other frameworks.

[Integrations](https://hanzo.ai/integrations)/Vercel AI SDK

▲Frameworks

# Use Hanzo AI with Vercel AI SDK

Use the Vercel AI SDK with Hanzo AI to build streaming AI UIs, chatbots, and generative interfaces in Next.js, React, and other frameworks.

Base URL: `https://api.hanzo.ai/v1`

API Key: Get yours at [hanzo.ai/signup](https://hanzo.ai/signup) · Fully OpenAI-compatible · 500+ models available

▲

Created by [Vercel](https://vercel.com)

License: Apache-2.0 · [View source on GitHub →](https://github.com/vercel/ai)

Hanzo AI is OpenAI-compatible, so existing Vercel AI SDK code works with zero refactoring. We deeply appreciate the Vercel team for building and maintaining this open-source project.

## Setup provider

typescript

```
npm install ai @ai-sdk/openai import { createOpenAI } from "@ai-sdk/openai"; const hanzo = createOpenAI({ baseURL: "https://api.hanzo.ai/v1", apiKey: process.env.HANZO_API_KEY, });
```

## generateText

typescript

```
import { generateText } from "ai"; import { createOpenAI } from "@ai-sdk/openai"; const hanzo = createOpenAI({ baseURL: "https://api.hanzo.ai/v1", apiKey: process.env.HANZO_API_KEY, }); const { text } = await generateText({ model: hanzo("zen4-pro"), prompt: "Write a poem about AI", });
```

## Streaming route handler

typescript

```
// app/v1/chat/route.ts import { streamText } from "ai"; import { createOpenAI } from "@ai-sdk/openai"; const hanzo = createOpenAI({ baseURL: "https://api.hanzo.ai/v1", apiKey: process.env.HANZO_API_KEY, }); export async function POST(req: Request) { const { messages } = await req.json(); const result = streamText({ model: hanzo("zen4-pro"), messages, }); return result.toDataStreamResponse(); }
```

## useChat hook

typescript

```
"use client"; import { useChat } from "ai/react"; export default function Chat() { const { messages, input, handleSubmit, handleInputChange } = useChat({ api: "/v1/chat", }); return ( Send

{messages.map((m) => {m.content}

)} ); }
```

## Ready to get started?

Create a free account and get your API key. 100K API calls/month free forever.

[Get API Key — Free](https://hanzo.ai/signup)[Browse Models](https://hanzo.ai/models)

## More integrations

[OpenAI Python SDK](https://hanzo.ai/integrations/openai-sdk)[Anthropic SDK](https://hanzo.ai/integrations/anthropic-sdk)[LangChain](https://hanzo.ai/integrations/langchain)[LlamaIndex](https://hanzo.ai/integrations/llamaindex)[Hugging Face](https://hanzo.ai/integrations/huggingface)[AutoGen](https://hanzo.ai/integrations/autogen)[CrewAI](https://hanzo.ai/integrations/crewai)[DSPy](https://hanzo.ai/integrations/dspy)[Haystack](https://hanzo.ai/integrations/haystack)[Cursor](https://hanzo.ai/integrations/cursor)[Continue.dev](https://hanzo.ai/integrations/continue-dev)[GitHub Copilot](https://hanzo.ai/integrations/github-copilot)[Docker](https://hanzo.ai/integrations/docker)[Kubernetes](https://hanzo.ai/integrations/kubernetes)[Python](https://hanzo.ai/integrations/python)[TypeScript](https://hanzo.ai/integrations/typescript)[Go](https://hanzo.ai/integrations/go)[Rust](https://hanzo.ai/integrations/rust)
