Setup instructions for different environments including development, testing, and local deployment.
Quick Start
The fastest way to get started with Guardway Gateway:
Clone the Repository
git clone https://github.com/guardwayai/agsec.git
cd agsec
Start with Docker Compose (includes all services)
Open Admin UI
open http://localhost:3000
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
Local Development
Docker Compose
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. Prerequisites : Docker 24+, Docker Compose v2# 1. Clone repository
git clone https://github.com/guardwayai/agsec.git
cd agsec
# 2. Create .env file
cp .env.example .env
# 3. Configure your API keys in .env
# Edit .env and add your provider API keys
# 4. Start all services
docker compose up -d
# 5. View logs
docker compose logs -f gateway
# 6. Stop services
docker compose down
Services included :
Gateway API (port 8000)
Admin UI (port 3000)
Redis (port 6379)
Environment Variables
Required Variables
HTTP server port for the gateway.
NODE_ENV
string
default: "development"
Environment mode.
REDIS_URL
string
default: "redis://localhost:6379"
Redis connection URL.
Master key used for admin operations. Example: sk-master-your-secure-random-key
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. Example: sk-...
Anthropic API key. Example: sk-ant-...
Groq API key. Example: gsk_...
Hugging Face API key. Example: hf_...
Optional Variables
Logging level. Options: debug, info, warn, error.
Log output format. Options: json or pretty.
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 distributed tracing.
Rate limiting window in milliseconds (default: 1 minute).
Maximum number of requests allowed per rate limit window.
Docker Compose Setup
Basic Configuration
With PostgreSQL
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
Log in with master key
Use your configured AGSEC_MASTER_KEY to authenticate.
Create organizations and API keys
Set up your organizational structure and generate API keys for your applications.
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
API returns 401 Unauthorized
Verify your API key is correct
Check master key is set correctly
Ensure API key hasn’t expired
Next Steps
After setting up your environment:
Configure : See Configuration for detailed configuration options
Deploy : See Deployment for production deployment
Use : See Usage Guide for examples and workflows