Proxy Advanced Usage
Proxy Advanced Usage
Section titled “Proxy Advanced Usage”The Swixter proxy gateway supports advanced routing, header injection, and traffic monitoring beyond the basic usage covered in Proxy Gateway commands.
Architecture
Section titled “Architecture”┌──────────┐ ┌──────────────┐ ┌──────────────┐│ AI Coder │ ──▶ │ Swixter Proxy│ ──▶ │ Provider API ││ (client) │ │ (localhost) │ │ (remote) │└──────────┘ └──────┬───────┘ └──────────────┘ │ ┌────▼────┐ │ Logger │ └─────────┘Configuration
Section titled “Configuration”Full proxy configuration in ~/.config/swixter/config.json:
{ "proxy": { "port": 18721, "host": "127.0.0.1", "autoStart": false, "logLevel": "debug", "timeout": 30000, "maxBodyLogSize": 4096, "headers": { "X-Custom-Header": "value" } }}| Option | Description | Default |
|---|---|---|
port | Listen port (0 = auto-assign) | 0 |
host | Listen address | "127.0.0.1" |
autoStart | Start proxy on profile apply | false |
logLevel | debug, info, warn, error | "info" |
timeout | Request timeout in ms | 30000 |
maxBodyLogSize | Max bytes to log per request/response body | 4096 |
headers | Additional headers to inject | {} |
Custom Routing
Section titled “Custom Routing”Route different models to different backends:
{ "proxy": { "routes": [ { "match": { "model": "claude-*" }, "upstream": "https://api.anthropic.com" }, { "match": { "model": "gpt-*" }, "upstream": "https://api.openai.com/v1" } ] }}Each route has:
match: Criteria to match (model,provider)upstream: URL to forward matching requests to
Header Injection
Section titled “Header Injection”Add custom headers to proxied requests:
{ "proxy": { "headers": { "X-Environment": "development", "X-Request-Source": "swixter-proxy" } }}Useful for:
- API gateway routing keys
- Usage tracking per environment
- Custom authentication middleware
Logging & Monitoring
Section titled “Logging & Monitoring”Log Levels
Section titled “Log Levels”# Detailed debug outputswixter proxy start --log-level debug
# Production mode (errors only)swixter proxy start --log-level errorLog Format
Section titled “Log Format”Each request is logged with:
{ "timestamp": "2026-04-29T10:30:00.000Z", "method": "POST", "path": "/v1/messages", "status": 200, "duration_ms": 1234, "request_size": 2048, "response_size": 512}Real-Time Logs
Section titled “Real-Time Logs”# Tail logsswixter proxy logs --follow
# Filter by status codeswixter proxy logs --status 4xx
# Last 50 requestsswixter proxy logs --last 50Performance
Section titled “Performance”The proxy adds minimal overhead (~1-5ms latency):
- Request/response body streaming (no buffering for large payloads)
- Connection pooling for upstream requests
- No TLS termination overhead (plain HTTP on localhost)
Security
Section titled “Security”- Proxy binds to
127.0.0.1by default (localhost only) - No external network access
- Headers are sanitized (Hop-by-hop headers removed)
- Body logging truncation prevents sensitive data leaks in logs