The Edge Function enforces a per-user, per-hour request cap using the openai_rate_limit table and increment_openai_usage() RPC (migration 20250219000000_openai_rate_limit.sql).
openai_rate_limit has RLS enabled with no client policies (intentional lockout). The proxy never queries the table directly; only the SECURITY DEFINER RPC may read/write it. See Docs/BACKEND.md → Intentional RLS lockout.
| Setting | Default | Where to change |
|---|---|---|
| Hourly limit | 50 requests / user / UTC hour | Edge Function secret OPENAI_HOURLY_LIMIT |
| Retry window | 3600 seconds | Returned as Retry-After on HTTP 429 |
openai-proxy with a valid Supabase JWT.increment_openai_usage(p_limit) with the user’s JWT (RPC uses auth.uid()).true if under the limit.Retry-After: 3600.# Supabase Dashboard → Edge Functions → openai-proxy → Secrets
OPENAI_HOURLY_LIMIT=100
Or via CLI after linking the project:
supabase secrets set OPENAI_HOURLY_LIMIT=100
select to_regclass('public.openai_rate_limit');
select proname from pg_proc where proname = 'increment_openai_usage';
Both should return a row in the Caluru project (opxqcnxiqbitezragpch).