feat(PBI-66): wekelijkse sync van model_prices via Anthropic /v1/models (#167)

Nieuw script `npm run db:sync-model-prices` haalt de actuele Claude 4.x
modellijst op bij de Anthropic API en upsert prijzen in `model_prices`.
Anthropic biedt geen prijs-API, dus prijzen blijven onderhouden in een
PRICE_TABLE constante in het script. Cache-tier-prijzen worden afgeleid
via vaste multipliers (read 0.1x, write 1.25x). Nieuwe Claude 4.x modellen
worden gedetecteerd en gelogd als warning zodat duidelijk is wanneer de
tabel handmatig moet worden bijgewerkt.

- scripts/sync-model-prices.ts: idempotent upsert, --dry-run, retry op 5xx
- ANTHROPIC_API_KEY als optional env-var (.env.example, lib/env.ts)
- scripts/README.md: gebruiksinstructies + edge cases
- docs/plans/sync-model-prices.md: ontwerpdocument

Verificatie: `npm run lint`, `vitest` (563/563), TypeScript clean.
Echt gedraaid tegen DB: 3 created (eerste run) -> 3 unchanged (tweede run).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-05-08 09:38:33 +02:00 committed by GitHub
parent 8a6b2d2cb3
commit eaabec8471
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 443 additions and 1 deletions

View file

@ -20,6 +20,9 @@ const envSchema = z.object({
)
.optional(),
INTERNAL_PUSH_SECRET: z.string().min(32).optional(),
// PBI-66 — Anthropic API key voor scripts/sync-model-prices.ts.
// Niet nodig in app-runtime, alleen bij het wekelijkse sync-script.
ANTHROPIC_API_KEY: z.string().optional(),
})
const parsed = envSchema.safeParse(process.env)