Infrastructure

Use Hanzo AI with Kubernetes

Deploy Hanzo AI-powered workloads on Kubernetes. Securely manage your Hanzo API key as a K8s secret and inject it into pods.

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

API Key: Get yours at hanzo.ai/signup · Fully OpenAI-compatible · 390+ models available

Created by CNCF / Google

License: Apache-2.0 · View source on GitHub →

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

K8s Secret

yaml
apiVersion: v1
kind: Secret
metadata:
  name: hanzo-credentials
  namespace: default
type: Opaque
stringData:
  api-key: "your-hanzo-api-key"

Deployment manifest

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ai-service
spec:
  replicas: 2
  selector:
    matchLabels:
      app: ai-service
  template:
    spec:
      containers:
        - name: app
          image: my-ai-app:latest
          env:
            - name: HANZO_API_KEY
              valueFrom:
                secretKeyRef:
                  name: hanzo-credentials
                  key: api-key
            - name: OPENAI_API_BASE
              value: "https://api.hanzo.ai/v1"

Apply to cluster

bash
kubectl create secret generic hanzo-credentials \
  --from-literal=api-key="your-hanzo-api-key"

kubectl apply -f deployment.yaml
kubectl get pods -l app=ai-service

HPA for AI workloads

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: ai-service-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: ai-service
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

Ready to get started?

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