Deployment Guide

Quick Start

Get up and running in minutes with our Python SDK.

1. Install the SDK

pip install agentcache

2. Drop-in Replacement

import agentcache

# Drop-in replacement for OpenAI
response = agentcache.completion(
    model="gpt-4",
    messages=[{"role": "user", "content": "What is Python?"}],
    provider="openai"
)

if response.get('hit'):
    print(f"💚 Cache hit! Saved ${response.get('billing', {}).get('cost_saved', 0)}")
    print(response['response'])
else:
    print("Cache miss - call your LLM provider normally")

Architecture

AgentCache sits between your application and AI providers, acting as an intelligent caching layer.

┌─────────────┐
│  Your App   │
└──────┬──────┘
       │
       ▼
┌─────────────────┐
│  AgentCache.ai  │◄──── Check cache first
└──────┬──────────┘
       │
    ┌──┴──┐
    │     │
    ▼     ▼
┌───────┐ ┌──────────┐
│  Hit  │ │   Miss   │
│ <50ms │ │ Call LLM │
│  $0   │ │ + Cache  │
└───────┘ └──────────┘

Tech Stack

  • Backend: Node.js + Hono (edge-compatible)
  • Cache: Upstash Redis (global low-latency)
  • Deploy: Vercel Edge Functions or Docker (Self-Hosted)

AgentCache Edge (Self-Hosted)

For air-gapped or high-compliance environments, deploy AgentCache Edge using Docker or Kubernetes.

Docker Compose

version: '3'
services:
  agentcache:
    image: xinetex/agentcache-edge:latest
    ports:
      - "3000:3000"
    environment:
      - REDIS_URL=redis://redis:6379
      - AGENTCACHE_API_KEY=your_secret_key
      - NODE_ENV=production
    depends_on:
      - redis

  redis:
    image: redis:alpine
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data

volumes:
  redis-data:

Run docker-compose up -d to start the service. Your local instance will be available at http://localhost:3000.

Kubernetes Deployment

For production environments, deploy using Kubernetes with Helm or raw manifests.

Helm Installation

helm repo add agentcache https://charts.agentcache.ai
helm install agentcache agentcache/agentcache-edge \
  --set redis.enabled=true \
  --set apiKey=your_secret_key \
  --set replicas=3

Kubernetes Manifests

apiVersion: apps/v1
kind: Deployment
metadata:
  name: agentcache-edge
spec:
  replicas: 3
  selector:
    matchLabels:
      app: agentcache
  template:
    metadata:
      labels:
        app: agentcache
    spec:
      containers:
      - name: agentcache
        image: xinetex/agentcache-edge:latest
        ports:
        - containerPort: 3000
        env:
        - name: REDIS_URL
          value: redis://redis-service:6379
        - name: AGENTCACHE_API_KEY
          valueFrom:
            secretKeyRef:
              name: agentcache-secrets
              key: api-key
---
apiVersion: v1
kind: Service
metadata:
  name: agentcache-service
spec:
  selector:
    app: agentcache
  ports:
  - port: 3000
    targetPort: 3000
  type: LoadBalancer

Air-Gapped Security

Deploy AgentCache in fully isolated environments without external internet access.

Offline Image Distribution

# Save Docker images
docker save xinetex/agentcache-edge:latest -o agentcache-edge.tar
docker save redis:alpine -o redis.tar

# Transfer to air-gapped environment, then load:
docker load -i agentcache-edge.tar
docker load -i redis.tar

Configuration for Isolated Networks

# docker-compose-airgapped.yml
version: '3'
services:
  agentcache:
    image: xinetex/agentcache-edge:latest
    ports:
      - "3000:3000"
    environment:
      - REDIS_URL=redis://redis:6379
      - AGENTCACHE_API_KEY=${AGENTCACHE_API_KEY}
      - AIR_GAPPED_MODE=true
      - DISABLE_TELEMETRY=true
      - DISABLE_UPDATES=true
    networks:
      - isolated

  redis:
    image: redis:alpine
    networks:
      - isolated
    volumes:
      - redis-data:/data

networks:
  isolated:
    internal: true

volumes:
  redis-data:

Security Features

  • No external calls: All data stays within your network perimeter
  • TLS termination: Configure at your load balancer or ingress
  • Audit logging: All cache operations logged locally
  • RBAC support: Namespace-based access control

Environment Variables

Configure AgentCache Edge with these environment variables.

REDIS_URL

Redis connection string (required)

REDIS_URL=redis://localhost:6379
AGENTCACHE_API_KEY

API key for authentication (required)

AGENTCACHE_API_KEY=your_secret_key_here
DATABASE_URL

PostgreSQL connection for analytics (optional)

DATABASE_URL=postgresql://user:pass@localhost:5432/agentcache
AIR_GAPPED_MODE

Enable for isolated environments (default: false)

AIR_GAPPED_MODE=true
LOG_LEVEL

Logging verbosity: debug, info, warn, error (default: info)

LOG_LEVEL=info
CACHE_TTL

Default cache TTL in seconds (default: 86400)

CACHE_TTL=86400

Production Best Practices

High Availability

  • Run at least 3 replicas for redundancy
  • Use Redis Cluster or Redis Sentinel for cache HA
  • Configure health checks: GET /health
  • Set up horizontal pod autoscaling based on CPU/memory

Monitoring

  • Prometheus metrics endpoint: /metrics
  • Monitor cache hit rate, latency, and error rates
  • Set up alerts for cache degradation
  • Track Redis memory usage and eviction rates

Security

  • Rotate API keys regularly (use Kubernetes secrets)
  • Enable TLS for Redis connections in production
  • Implement network policies to restrict traffic
  • Use namespace-based access control for multi-tenancy

Performance Tuning

  • Co-locate cache with application workloads (same region/AZ)
  • Use Redis pipelining for batch operations
  • Configure appropriate TTLs per namespace
  • Monitor and adjust Redis maxmemory policy

Need Help?

For enterprise deployments, compliance questions, or technical support: