Skip to main content
Setup instructions for different environments including development, testing, and local deployment.

Quick Start

The fastest way to get started with Guardway Gateway:
1

Clone the Repository

git clone https://github.com/guardwayai/agsec.git
cd agsec
2

Start with Docker Compose (includes all services)

docker compose up -d
3

Open Admin UI

open http://localhost:3000
4

Test the Gateway

curl http://localhost:8000/health
That’s it! The gateway is running at http://localhost:8000 and the admin UI at http://localhost:3000.

Development Setup

Prerequisites: Node.js 20+, pnpm 9+, Redis 7+
# 1. Clone and install dependencies
git clone https://github.com/guardwayai/agsec.git
cd agsec
pnpm install

# 2. Start Redis (required)
redis-server

# 3. Copy environment template
cp .env.example .env

# 4. Configure API keys in .env
# Edit .env and add your API keys:
# OPENAI_API_KEY=sk-...
# ANTHROPIC_API_KEY=sk-ant-...
# AGSEC_MASTER_KEY=sk-master-your-secure-key

# 5. Start the gateway
pnpm dev

# 6. Start the admin UI (optional, in another terminal)
cd apps/admin-ui
pnpm dev
The gateway will be available at http://localhost:8000 and admin UI at http://localhost:3000.

Environment Variables

Required Variables

PORT
number
default:"8000"
HTTP server port for the gateway.
NODE_ENV
string
default:"development"
Environment mode.
REDIS_URL
string
default:"redis://localhost:6379"
Redis connection URL.
AGSEC_MASTER_KEY
string
Master key used for admin operations. Example: sk-master-your-secure-random-key
CONFIG_ENCRYPTION_KEY
string
32-character encryption key for configuration encryption. Example: your-32-char-encryption-key-here

Provider API Keys

Add keys for the providers you want to use:
OPENAI_API_KEY
string
OpenAI API key. Example: sk-...
ANTHROPIC_API_KEY
string
Anthropic API key. Example: sk-ant-...
GOOGLE_API_KEY
string
Google (Gemini) API key.
GROQ_API_KEY
string
Groq API key. Example: gsk_...
MISTRAL_API_KEY
string
Mistral API key.
COHERE_API_KEY
string
Cohere API key.
HUGGINGFACE_API_KEY
string
Hugging Face API key. Example: hf_...

Optional Variables

LOG_LEVEL
string
default:"info"
Logging level. Options: debug, info, warn, error.
LOG_FORMAT
string
default:"json"
Log output format. Options: json or pretty.
DATABASE_URL
string
Optional PostgreSQL connection URL. Example: postgresql://user:pass@localhost:5432/agsec
OTEL_EXPORTER_OTLP_ENDPOINT
string
default:"http://localhost:4318"
OpenTelemetry exporter endpoint for observability.
ENABLE_TRACING
boolean
default:"true"
Enable distributed tracing.
RATE_LIMIT_WINDOW
number
default:"60000"
Rate limiting window in milliseconds (default: 1 minute).
RATE_LIMIT_MAX_REQUESTS
number
default:"100"
Maximum number of requests allowed per rate limit window.

Docker Compose Setup

version: '3.8'

services:
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    command: redis-server --appendonly yes

  gateway:
    image: guardway/gateway:latest
    ports:
      - "8000:8000"
    environment:
      - PORT=8000
      - REDIS_URL=redis://redis:6379
      - AGSEC_MASTER_KEY=${AGSEC_MASTER_KEY}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
    depends_on:
      - redis
    restart: unless-stopped

  admin-ui:
    image: guardway/admin-ui:latest
    ports:
      - "3000:3000"
    environment:
      - NEXT_PUBLIC_API_URL=http://localhost:8000
    depends_on:
      - gateway
    restart: unless-stopped

volumes:
  redis-data:

Verification

Health Check

# Check gateway health
curl http://localhost:8000/health

# Expected response:
# {"status":"ok","timestamp":"2025-01-23T...","uptime":123}

Test API

# Create an API key (requires master key)
curl -X POST http://localhost:8000/api/keys \
  -H "Authorization: Bearer ${AGSEC_MASTER_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "test-key",
    "budgetLimit": 10.00
  }'

# Test chat completion
curl -X POST http://localhost:8000/v1/chat/completions \
  -H "Authorization: Bearer ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Admin UI

1

Open the Admin UI

2

Log in with master key

Use your configured AGSEC_MASTER_KEY to authenticate.
3

Create organizations and API keys

Set up your organizational structure and generate API keys for your applications.
4

Monitor usage and costs

Track API usage, costs, and performance metrics from the dashboard.

Troubleshooting

# Check Docker logs
docker compose logs gateway
Common issues:
  • Missing API keys: Add them to .env
  • Redis not running: Run docker compose up redis -d
  • Port conflict: Change PORT in .env
# Test Redis connection
docker compose exec redis redis-cli ping
# Should return: PONG

# Check Redis logs
docker compose logs redis
  • Verify your API key is correct
  • Check master key is set correctly
  • Ensure API key hasn’t expired
  • Check Redis memory usage: docker compose exec redis redis-cli info memory
  • Monitor gateway logs: docker compose logs -f gateway
  • Increase Docker resource limits if needed

Next Steps

After setting up your environment:
  1. Configure: See Configuration for detailed configuration options
  2. Deploy: See Deployment for production deployment
  3. Use: See Usage Guide for examples and workflows