Example of AI server exposing a chat feature.
Add OPENAI_API_KEY env variable to run using OpenAI services.
- 100% Python stack with a modern
pyproject.tomltargeting Python 3.13, linters, formatters, and helpfulmake/CLI commands already wired up. - Backend-only template: no UI assets, just a FastAPI application you can extend with your own functionality.
- Includes a minimal chat endpoint that streams tokens so you can see how to build assistant-like experiences.
- Serves HTTP traffic through FastAPI running on the high-performance Granian worker.
- Ships with a CLI that lets you hit the sample chat flow directly from your terminal.
Dockerfileanddocker-compose.ymlare ready for local runs and container-based deployments out of the box.- Postgres configuration (init SQL, model config) and in-memory fallbacks are provided, along with setup instructions inside
config/. - JWT-based authorization is built in: drop your JWK set into
AUTH_TOKEN_SETSand every FastAPI route will enforce Bearer tokens automatically. - Adding OpenTelemetry is as simple as defining a single environment variable pointing to your OTEL exporter URL.
make venv– installs the pinneduvversion, clones.env, prepares git hooks, and syncs a managed Python 3.13 virtualenv.make sync/make update– syncs or upgrades dependencies usinguvso the lockfile stays authoritative.make format– applies Ruff fixes and formatting acrosssrc/.make lint– runs Bandit security checks, Ruff lint, and Pyright type analysis.make api– starts the FastAPI + Granian server (python -m api), perfect for local dev.make cli– launches the sample chat client; acceptsTHREAD_IDto resume conversations.make docker_run– rebuilds and runs the API service via Docker Compose;make sidekicksbrings up Postgres helpers.make migrations– executespython -m migrationsso schema changes stay in sync with Postgres.
- All API routes are wrapped with
JWTAuthorizedAPIRoute, so requests must sendAuthorization: Bearer <token>headers containing RS256 JWTs withiss,aud, andexpclaims. - Point the server at your signing keys by setting
AUTH_TOKEN_SETSto a JSON Web Key Set (seeconfig/.env.examplefor the format). Rotating keys is just a matter of updating that env var and restarting. - For the bundled CLI you can either paste a ready-made token into
CLI_API_TOKENor let it mint one on the fly by providingAUTH_TOKEN_PRIVATE_KEY(PEM string),AUTH_TOKEN_ISSUER, andAUTH_TOKEN_AUDIENCE. - Custom clients only need to generate a compatible JWT (matching the issuer/audience and any extra claims you enforce) and include it in the
Authorizationheader, making it easy to hook the template into your own IAM or identity provider.