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

@ -25,6 +25,12 @@ VAPID_SUBJECT="mailto:admin@example.com"
# Generate with: openssl rand -base64 32
INTERNAL_PUSH_SECRET=""
# PBI-66 — Anthropic API key voor `npm run db:sync-model-prices`.
# Optional. Alleen nodig om wekelijks de model_prices tabel te synchroniseren.
# Genereer op https://console.anthropic.com/ → API Keys.
# /v1/models is een gratis metadata-call (geen tokens, geen credit nodig).
ANTHROPIC_API_KEY=""
# v1-readiness item 2 — Sentry error monitoring.
# Optional. Without DSN, the SDK is a no-op (no network, no overhead).
# Get a DSN at https://sentry.io → Project → Settings → Client Keys (DSN).