Skip to content

Repository files navigation

aigloo

Self-hosted AI gateway
One endpoint · format translation · fallback routing · token saving · spend control · access keys · member usage

npm npm downloads Docker Pulls GHCR MIT Node ≥22.5

Features · Access keys · Quick Start · Token Savers · Config · CLI Tools


Why aigloo?

Every AI app speaks a different API format. Every provider has different keys, models, and rate limits. You juggle configs, hit quota walls mid-session, and lose track of spend.

aigloo fixes this. One local endpoint, one key. Point any app at it — Claude Code, opencode, Cursor, Codex, or anything that supports a custom base URL. It translates formats, routes across providers with automatic fallback, compresses token-heavy context, and tracks every cent.

npm install -g aigloo && aigloo

First run bootstraps everything. Subsequent runs start instantly.


How it works

  Your tools              aigloo                      Providers
  ──────────        ────────────────────         ──────────────
  Claude Code  ──┐                           ┌──► Anthropic
  opencode     ──┤  format translation       ├──► OpenAI
  Cursor       ──┼─► routing & fallback ─────┼──► OpenRouter
  Codex        ──┤  token compression        ├──► Gemini
  any app*     ──┘  spend tracking            └──► Ollama / custom
                     ▲
                     │
                one endpoint
                one API key

  * any app that supports a custom base URL + API key
  1. Add providers — paste your API keys, pick models. Use provider/model directly (key round-robin) or define combo aliases for multi-provider fallback chains
  2. Point your tools at http://localhost:18080 with a gateway key
  3. Track everything — per-request cost, tokens, budgets, and usage broken down by access key

Features

  • Format translation — OpenAI ↔ Anthropic on the fly, streaming included
  • Routing & fallback — use provider/model directly (key round-robin) or define combo aliases for multi-provider fallback chains; auto-rotates keys on 429/5xx/timeout
  • Pricing — per-model cost tracking with auto-fetched rates from models.dev (4000+ models) and LiteLLM as backup; manual overrides always win
  • Token savers — RTK compresses tool results, caveman trims prose, ponytail nudges minimal code, headroom compresses context — with per-request $ savings tracked on the Usage page
  • Access keys — hand someone (or another device) a key so they can use your aigloo personally — tools + optional usage login — with model allowlist, rate limit, rolling spend cap, and expiry
  • Member login — key holders open a usage-only dashboard (their spend & limits). Your password keeps the full console
  • Usage by key — admin Usage breaks down spend, tokens, and requests by access key for the selected window
  • Budgets — rolling spend caps (global/provider/model/key) with live countdown and per-token-type cost tracking
  • Alert notifications — webhook, Telegram, or Discord alerts when budgets hit their threshold or run out. Deduped per budget window
  • Dashboard — glassmorphic aigloo design: providers, combos, usage, budgets, CLI tools, live console, settings — all drag-to-reorder
  • Deploy anywhere — npm global install, from source, or Docker (Docker Hub + GHCR, multi-platform)

Endpoint page
Endpoint page — token saver toggles & endpoint config

Access Keys page
Access Keys — model allowlist, rate limit, spend cap per key

Budgets page
Budgets — rolling spend caps with live countdown


Access keys & member login

Who is an access key for? Anyone who should use aigloo themselves — Claude Code, Cursor, scripts, a second machine — without running the gateway or touching admin. You (the host) keep the password and the full console. You mint a key, set limits, and hand it over. They point their tools at your endpoint with that key and work as usual. Same key can open the dashboard in a member view so they can check their spend and remaining budget — not everyone else's, and not your providers or settings.

Think: roommate, teammate, side project, CI bot, laptop vs desktop. Shared gateway, personal usage.

Who Signs in with Sees / does
Admin (you) Dashboard password Full console — providers, keys, budgets, settings
Member (key holder) The access key you gave them Their API traffic + Usage only (spend, tokens, their limits)

As admin, create a key under Access Keys, set scope (models, RPM, spend cap window, expiry), copy it once, and share it. Spend caps are rolling windows (e.g. $10 every day) — they refill; they are not a one-shot total until the key dies. Key expiry is separate: after that date the key stops for both API and login.

As a key holder, open login → Access key tab, paste the key. You land on Usage with an access card (budget left + refill or lifetime total, models, expiry, RPM) and blocked-reason banners if something will fail. CLI Tools auto-detects and configures on this aigloo host with only your key and allowed models (best on localhost). No providers, no settings, no other people's keys.

Spend caps can be rolling ($10 every day) or lifetime (one-shot total that never refills).

Multi-tenant-lite: enough to share aigloo for personal use without giving away the house. Still one process, one config — not a full SaaS control plane.


Getting started

Quick start

npm install -g aigloo
aigloo

The CLI seeds config.yaml, builds the dashboard, opens your browser. One URL serves everything — dashboard, API, and admin: http://localhost:18080. Default admin password is 123456 — change it in Settings after first login.

A terminal menu offers: Web UI / Terminal (logs) / Hide to Tray (macOS · Linux · Windows) / Exit. Flags: -p/--port, -n/--no-browser, -y/--yes, -t/--tray.

From source

git clone https://github.com/xk1ko/aigloo.git
cd aigloo && npm install
cp config.example.yaml config.yaml   # add providers + a server key
npm install --prefix dashboard
./run.sh                              # Ctrl-C to stop

Docker

docker run -d -p 18080:18080 -v "$HOME/.aigloo:/data" --name aigloo xk1ko/aigloo:latest

Serves the same http://localhost:18080 — dashboard, API, and admin. See DOCKER.md for docker compose, env vars, and update instructions.

Connect your tools

# Claude Code (Anthropic format)
export ANTHROPIC_BASE_URL=http://localhost:18080
export ANTHROPIC_API_KEY=my-key

# opencode / Cursor / Cline / Codex (OpenAI format)
export OPENAI_BASE_URL=http://localhost:18080/v1
export OPENAI_API_KEY=my-key

The dashboard's CLI Tools page detects installed tools and writes configs for you.

Model resolution (in order): combo alias → provider/model.

Any app that supports a custom base URL + API key can use aigloo — just set the model to provider/model.


Supported CLI tools

Claude Code · opencode · Cursor · Codex · Cline · Continue · Roo · Aider · Gemini CLI · Qwen Code · Kilo Code · Crush · Droid · Copilot

Any app that supports a custom base URL + API key works — just set the model to provider/model.


Configuration

Everything is configurable from the dashboard — providers, combos, budgets, token savers, access keys, and settings. No need to edit files manually.

Under the hood, config.yaml is the source of truth and hot-reloads — any change made in the dashboard writes to this file instantly. You can also edit it by hand if you prefer; changes apply without restart.

config.yaml reference (click to expand)
server:
  host: 0.0.0.0
  port: 18080
  api_keys: [my-key]        # empty = auth OFF (localhost only)

endpoint:
  rtk: true                 # compress tool_result blocks
  caveman: full             # off | lite | full | ultra
  ponytail: lite            # off | lite | full | ultra
  headroom: { enabled: false }  # requires external headroom proxy running — see Token savers below

providers:
  - id: anthropic
    format: anthropic
    base_url: https://api.anthropic.com/v1
    api_keys: [sk-ant-xxx]
  - id: opencode-free
    format: openai
    base_url: https://opencode.ai/zen/v1
    free: true
    # auto_models: false    # fetch provider's /v1/models catalog (manual)

models:
  - alias: claude-sonnet-4-6
    target: [anthropic, opencode-free]   # fallback order
    model: [claude-sonnet-4-6, claude-sonnet-4-5]
    price_in: 3             # USD per 1M tokens
    price_out: 15

budgets:
  - scope: { type: global }
    unit: usd
    limit: 50
    window: 30day

A combo is a models entry — an alias routed to a provider chain. Strategies: fallback (default, sequential) or round-robin (spread load).


Token savers

Saver What it does Source Install
RTK Compresses bulky tool_result blocks (git/grep/ls/build logs, …) rtk-ai/rtk built-in port (updated with aigloo releases)
Caveman Terse system prompt — cuts output prose JuliusBrussee/caveman built-in port (updated with aigloo releases)
Ponytail Nudges minimal code (YAGNI, deletion) DietrichGebert/ponytail built-in port (updated with aigloo releases)
Headroom Pipes context through /v1/compress chopratejas/headroom external

Headroom is the only external dependency — install from chopratejas/headroom (Python ≥ 3.10), run headroom proxy. Without it the toggle stays off; everything else works.


Environment variables

Variable Purpose
AIGLOO_CONFIG Config file path
AIGLOO_DATA_DIR Usage DB directory
AIGLOO_ADMIN_PASSWORD Admin password — seeds on first boot, then stored as scrypt hash in auth.json. Default 123456
AIGLOO_PORT Listen port (default 18080)
SESSION_SECRET Dashboard session cookie signing key. Auto-generated and persisted if unset
AIGLOO_PRICING_SYNC_ENABLED Auto-fetch model pricing from models.dev + LiteLLM (default true). Set false to disable
AIGLOO_PRICING_SYNC_INTERVAL Pricing sync interval in seconds (default 86400 = 24h)

Admin password and provider keys never reach the browser — the dashboard proxies /admin/* server-side. Gateway access keys are different: they authenticate /v1 clients and can also open a member session on the login page.


Data location

OS Path
macOS / Linux ~/.aigloo/
Windows C:\Users\<name>\.aigloo\ (%USERPROFILE%\.aigloo)

Same folder name on every OS. Contains config.yaml and usage.sqlite. Delete the folder to reset everything.


Development

npm run typecheck       # tsc, no emit
npm test                # vitest (unit + synthetic E2E)
npm run build           # compile to dist/

⭐ Star this repo

If aigloo helps you, consider giving it a star — it helps others discover it.


Acknowledgements

Inspired by 9router — its feature set and dashboard shaped much of this project's direction.

License

MIT © xk1ko

Contributing

Issues and ideas welcome: https://github.com/xk1ko/aigloo/issues


Buy me a coffee

If aigloo saved you some tokens (or sanity), feel free to tip.

Donate EVM

0xB1D01f6972E75Bfd7dba1A1F490C21f3170E12Bd

About

Self-hosted AI gateway. Route, translate and track requests across providers, with access keys, budgets, and a built-in dashboard.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages