N2API is a personal AI API/account gateway for self-hosted use. It is inspired by sub2api's practical workflow, but it is a new implementation focused on personal use rather than platform billing or merchant operations.
- Go backend service.
- PostgreSQL as the default persistent database.
- Bun + SvelteKit + Tailwind CSS admin UI.
- Docker Compose first for local development and VPS deployment.
- Codex/OpenAI OAuth is the first upstream provider.
- OpenAI-compatible API routes and Codex-oriented adapter behavior share one internal gateway pipeline.
- No sub2api source-code fork or copy.
- No public registration, payment, recharge, balance, sponsor, invoice, merchant, or platform billing features.
- No Redis requirement in V1. Redis can be added later for optional distributed rate limiting, queues, or locks.
- No SQLite implementation in V1.
backend/ Go service entrypoint and future gateway/provider/store code
frontend/ Bun-managed SvelteKit admin UI
deploy/ Docker Compose and deployment notes
docs/ Design specs and implementation plans
Copy the environment template:
cp .env.example .envEdit .env and set real secrets before running the full stack.
OPENAI_API_BASE_URL defaults to https://api.openai.com and can be changed for compatible upstreams.
Backend:
cd backend
go test ./...
go run ./cmd/n2apiFrontend:
cd frontend
bun install
bun run check
bun run buildDocker Compose:
docker compose -f deploy/compose.yaml --env-file .env up --buildThe backend includes admin API key management, OpenAI/Codex OAuth account connection, request logs, static admin UI serving, and an initial OpenAI-compatible gateway for /v1/models, /v1/chat/completions, and core /v1/responses routes.