Thanks for helping improve liapi — a self-hosted, OpenAI-compatible API gateway written in pure Go standard library (no third-party module dependencies).
- Zero third-party dependencies.
go.modmust stay stdlib-only. If you need functionality, implement it in-tree or make a convincing case in an issue first. - Never log secrets. Tokens/API keys must be masked (
common.MaskToken) or omitted. Device tokens exist only as SHA-256 hashes at rest. - Keep the boundary. liapi is a gateway: it does not run model inference and is not a multi-tenant SaaS.
git clone https://github.com/LiStudioorg/liapi.git
cd liapi
go test ./...
go build -o liapi .
./liapi # first run creates ~/.li/liapi/config.json (mode 0600)Open the admin UI at http://localhost:8787/ and log in with the admin_token printed in the startup banner (mask it with LIAPI_MASK_ADMIN_TOKEN=1). Username/password login is off by default and credentials are never auto-generated — users enable it themselves (login_enabled + admin_username + admin_password in the config file, or the 配置 → 管理台与鉴权 panel).
All of these must pass locally (they also run in CI):
gofmt -l . # must print nothing
go vet ./...
go test ./...
go build ./...- Put tests next to the code:
foo.go→foo_test.go. - Core logic that must be covered: routing (fallback chains, strategies, aliases), retry/failover classification, limiter/quota windows, config validation, device auth.
- Prefer
httptestfor relay/HTTP tests; inject a fake clock (SetNow) for time-based logic instead oftime.Sleep.
- One concern per PR; include motivation and a short test plan in the description.
- Config/schema changes: update the field table in
README.mdand mention migration impact. - Do not bump
godirective without discussion.
Maintainers tag vX.Y.Z; .github/workflows/release.yml cross-compiles via buildrelease.sh (version injected into main.version).
| Package | Responsibility |
|---|---|
config |
Schema, validation, atomic save, hot-reload holder, OneAPI interop |
auth |
Client/device/admin authentication |
routing |
Candidate selection: fallback chains, priority/latency/cost, aliases |
relay |
Forwarding, retry/failover classification, SSE copy, usage extraction |
server |
HTTP handlers, request-id, admin API, metrics |
stats |
Sliding-window limiter, daily quota, JSONL logger, health probes, metrics, aggregation |
common |
Errors (OpenAI format), token hashing/masking |
- Bugs: GitHub issues with repro steps.
- Security: see SECURITY.md — do not file public issues for vulnerabilities.