# Use Hanzo AI with DSPy — Hanzo AI > Use DSPy to program (not prompt) Hanzo AI models. DSPy's systematic approach to LM prompting works with any OpenAI-compatible provider. [Integrations](https://hanzo.ai/integrations)/DSPy 🔬Frameworks # Use Hanzo AI with DSPy Use DSPy to program (not prompt) Hanzo AI models. DSPy's systematic approach to LM prompting works with any OpenAI-compatible provider. 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 [Stanford NLP / Omar Khattab](https://dspy.ai) License: MIT · [View source on GitHub →](https://github.com/stanfordnlp/dspy) Hanzo AI is OpenAI-compatible, so existing DSPy code works with zero refactoring. We deeply appreciate the Stanford NLP / Omar Khattab team for building and maintaining this open-source project. ## DSPy + Hanzo setup python ``` pip install dspy import dspy lm = dspy.LM( model="openai/zen4-pro", api_key="your-hanzo-api-key", api_base="https://api.hanzo.ai/v1", ) dspy.configure(lm=lm) ``` ## Signature and module python ``` class QA(dspy.Signature): """Answer questions with short factual answers.""" question: str = dspy.InputField() answer: str = dspy.OutputField(desc="often 1-3 sentences") qa = dspy.Predict(QA) response = qa(question="What is the Hanzo AI cloud?") print(response.answer) ``` ## Chain of thought python ``` class CoTQA(dspy.Signature): """Answer with step-by-step reasoning.""" question: str = dspy.InputField() reasoning: str = dspy.OutputField(desc="think step by step") answer: str = dspy.OutputField() cot = dspy.ChainOfThought(CoTQA) result = cot(question="Why is AI important for developers?") ``` ## Optimization with MIPROv2 python ``` from dspy.teleprompt import MIPROv2 teleprompter = MIPROv2(metric=my_metric, auto="medium") optimized = teleprompter.compile(program, trainset=train_data) ``` ## 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)[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)