API for agents: tokens, /api/v1 for downloads, verify, repair, tags

Brings back the token API that 0.15 removed with deployments, for
models only, ported onto the current code (local models, lean client
bundles, MiB-rounded disk space):

- Scoped bearer tokens (models:read, downloads:create, models:verify,
  tags:write), stored as SHA-256, managed in Settings -> API tokens.
  Only /api/v1 accepts them; the rest stays OIDC-only.
- /api/v1: Hub lookup, library with the search filters, download
  requests through the add-model/queue path (idempotent), repair of
  missing or broken files, verify / deep verify, tags, job status with
  ?wait=, cancelling or withdrawing the token's own jobs, disk space.
- Guardrails for downloads and repairs: approval (default ask), max
  size per request, minimum free space incl. reserved bytes, agent jobs
  at once, author allowlist (new downloads only). Approve/reject in the
  UI, "requested by" badges and filter, activity log per token.
- Migration 0027 adds api_tokens, agent_activity and requested_by
  columns on models and jobs; job state pending_approval.
- docs/api.md, docs/agent/SKILL.md and the kaname curl helper; DB-backed
  API tests. The login gate test now expects /api/v1 to be left to
  token auth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-11-11 21:52:28 +01:00
1 parent 7d1a8fb85a
commit 0e0445a418
63 files changed
+5448 -42

No files matched your search

+9
View File
@@ -17,6 +17,9 @@ their speed and answer quality with [BetterBench](https://github.com/GGZ14/Bette
- **Benchmark your endpoints:** speed runs, paired A/B tests and a quality eval against any
OpenAI-compatible server, with the hardware you describe recorded next to every number; publish
results to [launch80](https://launch80.com) if you like.
- **Let AI agents fetch models:** a token-authenticated API (`/api/v1`) to look up, download,
verify, repair and tag models, within guardrails you set and, by default, only after you approve
each download. A ready-made [agent skill](docs/agent/SKILL.md) explains it to the agent.
- **Homelab-friendly:** a few containers, SQLite, OIDC single sign-on (e.g. Pocket ID), models on any
folder or NAS share. Kaname needs no access to Docker.
@@ -133,6 +136,12 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname
Describe the machine behind it (GPUs, PCIe link, CPU, RAM, OS, engine build, quant, KV cache):
Kaname can't see it, and these notes go into every run so results stay comparable. The API key
stays on the server.
- **Agents and scripts:** create a token under Settings → API tokens (pick its scopes), set the
guardrails (approval, max size per request, free space to keep, jobs at once, allowed authors),
and hand the agent [docs/agent/SKILL.md](docs/agent/SKILL.md) with `KANAME_URL` and
`KANAME_TOKEN`. Its requests show up as **requested by &lt;token&gt;** with an Approve / Reject bar;
every request and refusal is in the token's activity log. Reference: [docs/api.md](docs/api.md).
Behind forward auth, let `/api/v1/` through (Kaname checks the token itself; example in the doc).
- **Benchmarks:** from an endpoint's page, start a BetterBench **speed** run (generation, prompt
processing, parallel requests), a paired **A/B** against another endpoint serving the same model,
or the **quality** eval (tool calling, coding, long-context retrieval; deterministic). Runs go one