Production-grade LLM Gateway in Go. Ledger sits between applications and AI providers (OpenAI, Anthropic/Claude, Gemini), giving a unified OpenAI-compatible API with cost control, reliability, and observability — so you always know what your AI usage costs, and a provider outage never takes your app down with it.
See ARCHITECTURE.md for the full system design, including package responsibilities, request lifecycle, schema, and build order.
🚧 Phase 1 (MVP) in progress. Not production-ready yet.
- Go 1.24+
- Docker and Docker Compose (local Postgres + Redis)
- golang-migrate CLI (for database migrations)
- Start local dependencies:
docker compose up -d- Build and run using the example config (defaults work for local dev):
make build
make run CONFIG=configs/config.example.yamlTo customize settings, copy the example config first and point CONFIG at your copy:
cp configs/config.example.yaml configs/config.yaml
make run CONFIG=configs/config.yaml| Target | Description |
|---|---|
make build |
Build the ledger binary to bin/ledger |
make run |
Build and run with CONFIG (default: configs/config.example.yaml) |
make test |
Run all unit tests |
make migrate-up |
Apply pending database migrations |
make migrate-down |
Roll back the last migration |
make tidy |
Run go mod tidy |
Configuration is loaded from a YAML file (see configs/config.example.yaml).
- Pass
--config path/to/config.yamlto the binary ${ENV_VAR}placeholders in YAML are expanded from the environment- Environment overrides (take precedence over YAML):
DATABASE_URL— Postgres connection stringREDIS_URL— Redis connection stringOPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY— provider credentials
Invalid configuration fails at startup with a descriptive error.
See ARCHITECTURE.md for the full layout and package responsibilities.
MIT