Quick Deploy (Production Agent)
Quick Deploy (Production Agent)
Deploy a production-ready HUMΛN agent in under 5 minutes.
This pattern shows you how to take an agent from development to production using HUMΛN's flexible deployment options: hosted, containers, or serverless.
When to Use This
- ✅ You have a working agent in development
- ✅ You need to deploy to production quickly
- ✅ You want auto-scaling and monitoring built-in
- ✅ You need zero-downtime deployments
Architecture
┌─────────────────────────────────────────────────┐
│ HUMΛN Cloud (Hosted) │
│ ┌──────────────────────────────────────────┐ │
│ │ Your Agent Code (containerized) │ │
│ │ ├── Agent logic │ │
│ │ ├── HUMΛN SDK │ │
│ │ └── Health checks │ │
│ └──────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────┐ │
│ │ HumanOS Orchestration Engine │ │
│ │ ├── Task routing │ │
│ │ ├── Human-in-the-loop │ │
│ │ └── Capability matching │ │
│ └──────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────┐ │
│ │ Passport + Capability Graph │ │
│ │ (Identity and permissions) │ │
│ └──────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
Prerequisites
- HUMΛN account and API key
- Agent code ready (TypeScript, Python, or Go)
- Docker installed (for containerized deployments)
Implementation
Step 1: Prepare Your Agent
Ensure your agent is production-ready with health checks and error handling:
typescript:TypeScript
```typescript
// src/index.ts
import { HumanClient } from '@human/sdk';
import express from 'express';
const human = new HumanClient({
apiKey: process.env.HUMAN_API_KEY!,
passportId: process.env.HUMAN_PASSPORT_ID!,
});
const app = express();
app.use(express.json());
// Health check endpoints
app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: Date.now() });
});
app.get('/ready', async (req, res) => {
try {
// Check HUMΛN connectivity
await human.passport.verify(process.env.HUMAN_PASSPORT_ID!);
res.json({ status: 'ready' });
} catch (error) {
res.status(503).json({ status: 'not_ready', error });
}
});
// Agent task handler
app.post('/process', async (req, res) => {
try {
const result = await human.call({
task: 'process_document',
input: req.body,
riskLevel: 'medium',
});
res.json(result);
} catch (error) {
console.error('Task failed:', error);
res.status(500).json({ error: 'Processing failed' });
}
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Agent running on port ${PORT}`);
});
```
python:Python
```python
# app.py
from flask import Flask, request, jsonify
from human_sdk import HumanClient
import os
app = Flask(__name__)
human = HumanClient(
api_key=os.environ['HUMAN_API_KEY'],
passport_id=os.environ['HUMAN_PASSPORT_ID'],
)
@app.route('/health')
def health():
return jsonify({"status": "ok", "timestamp": int(time.time())})
@app.route('/ready')
def ready():
try:
# Check HUMΛN connectivity
human.passport.verify(os.environ['HUMAN_PASSPORT_ID'])
return jsonify({"status": "ready"})
except Exception as e:
return jsonify({"status": "not_ready", "error": str(e)}), 503
@app.route('/process', methods=['POST'])
def process():
try:
result = human.call(
task='process_document',
input=request.json,
risk_level='medium',
)
return jsonify(result)
except Exception as e:
return jsonify({"error": "Processing failed"}), 500
if __name__ == '__main__':
port = int(os.environ.get('PORT', 3000))
app.run(host='0.0.0.0', port=port)
```
go:Go
```go
// main.go
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"time"
human "github.com/human/sdk-go"
)
var client *human.Client
func main() {
client = human.NewClient(
human.WithAPIKey(os.Getenv("HUMAN_API_KEY")),
human.WithPassportID(os.Getenv("HUMAN_PASSPORT_ID")),
)
http.HandleFunc("/health", healthHandler)
http.HandleFunc("/ready", readyHandler)
http.HandleFunc("/process", processHandler)
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
log.Printf("Agent running on port %s", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
func healthHandler(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]interface{}{
"status": "ok",
"timestamp": time.Now().Unix(),
})
}
func readyHandler(w http.ResponseWriter, r *http.Request) {
_, err := client.Passport.Verify(os.Getenv("HUMAN_PASSPORT_ID"))
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
json.NewEncoder(w).Encode(map[string]string{
"status": "not_ready",
"error": err.Error(),
})
return
}
json.NewEncoder(w).Encode(map[string]string{"status": "ready"})
}
func processHandler(w http.ResponseWriter, r *http.Request) {
var input map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
http.Error(w, "Invalid request", http.StatusBadRequest)
return
}
result, err := client.Call(&human.CallRequest{
Task: "process_document",
Input: input,
RiskLevel: "medium",
})
if err != nil {
http.Error(w, "Processing failed", http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(result)
}
```
bash:REST API
```bash
# Test health check
curl https://your-agent.example.com/health
# Test readiness
curl https://your-agent.example.com/ready
# Process a task
curl -X POST https://your-agent.example.com/process \\
-H "Content-Type: application/json" \\
-d '{
"document_id": "doc_123",
"content": "Invoice data..."
}'
```
Step 2: Create Dockerfile
Containerize your agent for portable deployment:
bash:TypeScript Dockerfile
```bash
# Dockerfile
FROM node:20-alpine
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm ci --only=production
# Copy application code
COPY . .
# Build TypeScript
RUN npm run build
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
CMD node healthcheck.js || exit 1
# Run as non-root user
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]
```
bash:Python Dockerfile
```bash
# Dockerfile
FROM python:3.11-slim
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
CMD python healthcheck.py || exit 1
# Run as non-root user
RUN useradd -m -u 1000 human && chown -R human:human /app
USER human
EXPOSE 3000
CMD ["gunicorn", "--bind", "0.0.0.0:3000", "--workers", "4", "app:app"]
```
bash:Go Dockerfile
```bash
# Dockerfile
# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o agent .
# Runtime stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/agent .
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
EXPOSE 3000
CMD ["./agent"]
```
Step 3: Deploy to Production
Choose your deployment method:
Option A: HUMΛN Cloud (Fastest)
bash:TypeScript
```bash
# Deploy to HUMΛN Cloud (zero-config)
npx @human/cli deploy
# Output:
# Agent deployed in 2 minutes
# URL: https://my-agent-abc123.human.ai
# Auto-scaling: 1-100 instances
# Monitoring: https://console.human.ai/agents/my-agent
```
bash:Python
```bash
# Deploy to HUMΛN Cloud
human-cli deploy
# Output:
# Agent deployed
# URL: https://my-agent-abc123.human.ai
# Runtime: Python 3.11
```
bash:Go
```bash
# Deploy to HUMΛN Cloud
human-cli deploy
# Output:
# Agent deployed
# URL: https://my-agent-abc123.human.ai
# Runtime: Go 1.21
```
Option B: Docker Container
bash:Docker CLI
```bash
# Build image
docker build -t myorg/my-agent:v1.0.0 .
# Run locally (test)
docker run -d \\
--name my-agent \\
-e HUMAN_API_KEY=$HUMAN_API_KEY \\
-e HUMAN_PASSPORT_ID=$HUMAN_PASSPORT_ID \\
-p 3000:3000 \\
myorg/my-agent:v1.0.0
# Push to registry
docker push myorg/my-agent:v1.0.0
# Deploy to production
docker run -d \\
--name my-agent-prod \\
--restart unless-stopped \\
-e HUMAN_API_KEY=$HUMAN_API_KEY \\
-e HUMAN_PASSPORT_ID=$HUMAN_PASSPORT_ID \\
-p 80:3000 \\
myorg/my-agent:v1.0.0
```
yaml:Kubernetes
```yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-agent
spec:
replicas: 3
selector:
matchLabels:
app: my-agent
template:
metadata:
labels:
app: my-agent
spec:
containers:
- name: agent
image: myorg/my-agent:v1.0.0
ports:
- containerPort: 3000
env:
- name: HUMAN_API_KEY
valueFrom:
secretKeyRef:
name: human-credentials
key: api-key
- name: HUMAN_PASSPORT_ID
value: "passport_abc123"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "1000m"
---
apiVersion: v1
kind: Service
metadata:
name: my-agent
spec:
selector:
app: my-agent
ports:
- port: 80
targetPort: 3000
type: LoadBalancer
```
yaml:Docker Compose
```yaml
# docker-compose.yml
version: '3.8'
services:
agent:
image: myorg/my-agent:v1.0.0
environment:
HUMAN_API_KEY: ${HUMAN_API_KEY}
HUMAN_PASSPORT_ID: ${HUMAN_PASSPORT_ID}
ports:
- "80:3000"
restart: unless-stopped
deploy:
replicas: 3
resources:
limits:
cpus: '1'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
```
Option C: Serverless
yaml:AWS Lambda (serverless.yml)
```yaml
# Serverless Framework configuration
service: my-agent
provider:
name: aws
runtime: nodejs20.x
region: us-east-1
environment:
HUMAN_API_KEY: ${env:HUMAN_API_KEY}
HUMAN_PASSPORT_ID: ${env:HUMAN_PASSPORT_ID}
functions:
process:
handler: handler.process
events:
- http:
path: process
method: post
timeout: 30
memorySize: 1024
```
bash:Deploy CLI
```bash
# Deploy to AWS Lambda
sls deploy --stage production
```
bash:Google Cloud Run
```bash
# Deploy to Cloud Run
gcloud run deploy my-agent \\
--image gcr.io/myproject/my-agent:v1.0.0 \\
--platform managed \\
--region us-central1 \\
--set-env-vars HUMAN_API_KEY=$HUMAN_API_KEY \\
--set-env-vars HUMAN_PASSPORT_ID=$HUMAN_PASSPORT_ID \\
--allow-unauthenticated \\
--min-instances 1 \\
--max-instances 100 \\
--cpu 2 \\
--memory 2Gi \\
--concurrency 80
# Output:
# Deployed to: https://my-agent-abc123-uc.a.run.app
# Auto-scales 1-100 instances
# Pay-per-request pricing
```
bash:Azure Functions
```bash
# Deploy to Azure Functions
az functionapp deployment source config-zip \\
--resource-group myResourceGroup \\
--name my-agent \\
--src dist.zip
az functionapp config appsettings set \\
--name my-agent \\
--resource-group myResourceGroup \\
--settings \\
HUMAN_API_KEY=$HUMAN_API_KEY \\
HUMAN_PASSPORT_ID=$HUMAN_PASSPORT_ID
```
Step 4: Verify Deployment
Test your production deployment:
bash:Hosted
```bash
# Get deployment status
npx @human/cli status my-agent
Agent: my-agent
Status: Running
Instances: 3/3 healthy
URL: https://my-agent-abc123.human.ai
Last Deploy: 2 minutes ago
# View logs
npx @human/cli logs my-agent --tail 100
# Monitor metrics
npx @human/cli metrics my-agent
```
bash:Container
```bash
# Check container health
docker ps | grep my-agent
# View logs
docker logs my-agent --tail 100 --follow
# Test health endpoint
curl http://localhost:3000/health
# Test processing
curl -X POST http://localhost:3000/process \\
-H "Content-Type: application/json" \\
-d '{"test": "data"}'
```
bash:Kubernetes
```bash
# Check deployment status
kubectl get deployments
kubectl get pods -l app=my-agent
# View logs
kubectl logs -f deployment/my-agent
# Port forward for testing
kubectl port-forward deployment/my-agent 3000:3000
# Scale up
kubectl scale deployment my-agent --replicas=5
```
Related Patterns
- Build First Agent - Create an agent from scratch
- Invoice Processor - Full production example