# Use Hanzo AI with Go — Hanzo AI > Use Hanzo AI in Go using the official OpenAI Go client or any OpenAI-compatible Go library. Hanzo's standard REST API works with all HTTP clients. [Integrations](https://hanzo.ai/integrations)/Go 🐹Languages # Use Hanzo AI with Go Use Hanzo AI in Go using the official OpenAI Go client or any OpenAI-compatible Go library. Hanzo's standard REST API works with all HTTP clients. 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 [Go Authors / Google](https://go.dev) License: BSD-3-Clause · [View source on GitHub →](https://github.com/golang/go) Hanzo AI is OpenAI-compatible, so existing Go code works with zero refactoring. We deeply appreciate the Go Authors / Google team for building and maintaining this open-source project. ## OpenAI Go client go ``` go get github.com/openai/openai-go package main import ( "context" "fmt" "github.com/openai/openai-go" "github.com/openai/openai-go/option" ) func main() { client := openai.NewClient( option.WithBaseURL("https://api.hanzo.ai/v1"), option.WithAPIKey("your-hanzo-api-key"), ) resp, _ := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{ Model: openai.F("zen4-pro"), Messages: openai.F([]openai.ChatCompletionMessageParamUnion{ openai.UserMessage("Hello from Go!"), }), }, ) fmt.Println(resp.Choices[0].Message.Content) } ``` ## Raw HTTP client go ``` package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" "os" ) func main() { body, _ := json.Marshal(map[string]any{ "model": "zen4-pro", "messages": []map[string]string{{"role": "user", "content": "Hello!"}}, }) req, _ := http.NewRequest("POST", "https://api.hanzo.ai/v1/chat/completions", bytes.NewReader(body)) req.Header.Set("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY")) req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() io.Copy(os.Stdout, resp.Body) fmt.Println() } ``` ## Streaming go ``` stream, _ := client.Chat.Completions.NewStreaming(context.Background(), openai.ChatCompletionNewParams{ Model: openai.F("zen4-pro"), Messages: openai.F([]openai.ChatCompletionMessageParamUnion{ openai.UserMessage("Write a poem"), }), }, ) defer stream.Close() for stream.Next() { chunk := stream.Current() if len(chunk.Choices) > 0 { fmt.Print(chunk.Choices[0].Delta.Content) } } ``` ## Environment bash ``` export HANZO_API_KEY="your-hanzo-api-key" go run main.go ``` ## 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)[Vercel AI SDK](https://hanzo.ai/integrations/vercel-ai-sdk)[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)[Rust](https://hanzo.ai/integrations/rust)