ClipSpacesClipSpaces Docs
Back to app

All releases

Clip AI credit metering

Added

  • Message credits for Clip AI. Each host-key message (brief or chat turn) now spends one credit against a per-user allowance — 30 messages / 3h by default (overridable via AI_CREDIT_LIMIT / AI_CREDIT_WINDOW_HOURS). The window is a fixed rolling window that resets on the first request after it elapses. When the allowance is exhausted the AI route returns 429 with a friendly "resets in Xh Ym" message and a nudge to add your own key.
  • Usage meter in AI settings (Settings → Clip AI) — a progress bar showing used / limit, remaining, and when it resets. Turns amber near the cap and red when reached. Users on their own key see "Unlimited on your key" instead.
  • Storage + atomic windowed increment in public.ai_usage / public.consume_ai_credit (migration 20260708000100_ai_usage.sql); read-only snapshot at GET /api/ai/usage. Metering fails open — a DB hiccup never blocks a message.

Changed

  • ResolvedAIConfig carries an ownKey flag so the route can tell host-key usage (metered) from bring-your-own-key usage (unmetered — billed to the user's provider).