npm.io
1.5.0 • Published 22h agoCLI

aigetwey

Licence
MIT
Version
1.5.0
Deps
5
Size
36.4 MB
Vulns
0
Weekly
3.6K
DeprecatedThis package is deprecated

aigetwey

Personal AI gateway — one endpoint, every app
One endpoint · format translation · fallback routing · token saving · spend control

npm MIT Node ≥22

Features · Quick Start · Token Savers · Config · Bahasa Indonesia


Why aigetwey?

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.

aigetwey 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 aigetwey && aigetwey

First run bootstraps everything. Subsequent runs start instantly.


Features

  • Format translation — OpenAI Anthropic on the fly, streaming included
  • Fallback routing — combo alias → provider chain; auto-rotates keys on 429/5xx/timeout
  • Token savers — RTK compresses tool results, caveman trims prose, ponytail nudges minimal code, headroom compresses context
  • Access keys — share gateway keys with model allowlist, rate limit, spend cap, and expiry
  • Budgets — rolling spend caps (global/provider/model/key) with live countdown and per-token-type cost tracking
  • Dashboard — providers, combos, usage, budgets, CLI tools, live console, settings — all drag-to-reorder

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


Getting started

Quick start
npm install -g aigetwey
aigetwey

The CLI seeds config.yaml, builds the dashboard, opens your browser. One URL serves everything — dashboard, API, and admin: http://localhost:18080.

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

From source
git clone https://github.com/xk1ko/aigetwey.git
cd aigetwey && npm install
cp config.example.yaml config.yaml   # add providers + a server key
npm install --prefix dashboard
./run.sh                              # Ctrl-C stops both
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 aigetwey — 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: off             # off | on — requires external headroom proxy

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) rtk-ai/rtk built-in
Caveman Terse system prompt — cuts output prose JuliusBrussee/caveman built-in
Ponytail Nudges minimal code (YAGNI, deletion) DietrichGebert/ponytail built-in
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
AIGETWEY_CONFIG Config file path
AIGETWEY_DATA_DIR Usage DB directory
AIGETWEY_ADMIN_PASSWORD Admin + dashboard auth
AIGETWEY_PORT Listen port

Dashboard (dashboard/.env.local): GATEWAY_URL, ADMIN_PASSWORD, SESSION_SECRET.

Admin password and provider keys never reach the browser — the dashboard proxies /admin/* server-side.


Development

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

Memulai

Mulai cepat
npm install -g aigetwey
aigetwey

Run pertama bootstrap otomatis — buat config.yaml, build dashboard, buka browser. Satu URL untuk semuanya: http://localhost:18080.

Menu terminal: Web UI / Terminal (logs) / Hide to Tray (macOS + Linux) / Exit.

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

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

Halaman CLI Tools di dashboard mendeteksi tool dan menulis config otomatis. App lain yang support custom base URL + API key bisa langsung pakai dengan model provider/model.

Fitur utama
  • Format translation — translate OpenAI Anthropic otomatis, termasuk streaming
  • Fallback routing — alias model → rantai provider; rotasi key saat 429/5xx/timeout
  • Token savers — RTK, Caveman, Ponytail (built-in) + Headroom (eksternal)
  • Access keys — bagi key dengan allowlist model, rate limit, batas spend, kedaluwarsa
  • Budgets — spend cap rolling (5h/24h/7day/30day) dengan countdown dan tracking per jenis token
  • Dashboard — providers, combos, usage, budgets, CLI tools, console live, settings
Penghemat token

RTK, Caveman, Ponytail = built-in. Hanya Headroom yang eksternal (Python, headroom proxy). Tanpa Headroom toggle-nya mati, sisanya tetap jalan.

Konfigurasi

config.yaml hot-reload — edit lewat dashboard/API langsung berlaku tanpa restart. Lihat config.example.yaml untuk semua bentuk provider.

Combo = entry models: alias → rantai provider. Strategy: fallback (default) atau round-robin.

Resolusi model: alias combo → provider/model.

Environment

Gateway: AIGETWEY_CONFIG, AIGETWEY_DATA_DIR, AIGETWEY_ADMIN_PASSWORD, AIGETWEY_PORT. Dashboard: GATEWAY_URL, ADMIN_PASSWORD, SESSION_SECRET.

Password admin dan key provider tidak pernah sampai ke browser.


Star this repo

If aigetwey 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/aigetwey/issues

Keywords