fairvisor init
fairvisor init creates two starter files in the current directory:
policy.json— a policy bundle pre-filled for the chosen use-case templateedge.env.example— environment variable template for configuring the edge container
Synopsis
fairvisor init [--template=api|llm|webhook]
Options
| Flag | Default | Description |
|---|---|---|
--template |
api |
Starter template to use: api, llm, or webhook |
Templates
api (default)
Generic API rate limiting by API key. Suitable for REST APIs.
{
"bundle_version": 1,
"policies": [{
"id": "api-rate-limit",
"spec": {
"selector": { "pathPrefix": "/", "methods": ["GET", "POST", "PUT", "DELETE"] },
"mode": "enforce",
"rules": [{
"name": "per-key-limit",
"limit_keys": ["header:x-api-key"],
"algorithm": "token_bucket",
"algorithm_config": {
"tokens_per_second": 100,
"burst": 200
}
}]
}
}],
"kill_switches": []
}
llm
LLM token-rate limiting by org claim in JWT. Suitable for /v1/chat/completions style endpoints.
{
"bundle_version": 1,
"policies": [{
"id": "llm-rate-limit",
"spec": {
"selector": { "pathExact": "/v1/chat/completions", "methods": ["POST"] },
"mode": "enforce",
"rules": [{
"name": "llm-token-budget",
"limit_keys": ["jwt:org_id"],
"algorithm": "token_bucket_llm",
"algorithm_config": {
"tokens_per_minute": 120000,
"tokens_per_day": 2000000,
"burst_tokens": 120000,
"default_max_completion": 1024
}
}]
}
}],
"kill_switches": []
}
webhook
Webhook delivery rate limiting by sender IP, suitable for inbound webhook receivers.
{
"bundle_version": 1,
"policies": [{
"id": "webhook-rate-limit",
"spec": {
"selector": { "pathPrefix": "/webhooks/", "methods": ["POST"] },
"mode": "enforce",
"rules": [{
"name": "per-ip-limit",
"limit_keys": ["ip:address"],
"algorithm": "token_bucket",
"algorithm_config": {
"tokens_per_second": 10,
"burst": 50
}
}]
}
}],
"kill_switches": []
}
Generated edge.env.example
FAIRVISOR_EDGE_ID=
FAIRVISOR_EDGE_TOKEN=
FAIRVISOR_SAAS_URL=https://api.fairvisor.com
FAIRVISOR_EDGE_URL=http://localhost:8080
Copy this to .env or edge.env and fill in the values from your SaaS dashboard before running fairvisor connect.
Examples
# Create default (api) template
fairvisor init
# Create LLM template
fairvisor init --template=llm
# Create webhook template in a specific directory
cd /etc/fairvisor && fairvisor init --template=webhook
Exit codes
| Code | Meaning |
|---|---|
0 |
Files created successfully |
1 |
Failed to write files (check permissions) |
3 |
Unknown template name |