← Gatekeeper

Documentation

Need help? Contact support →

AI proxy

POST /api/ai-proxy

Use this streaming endpoint for OpenAI, Anthropic, and OpenAI-compatible providers. It returns server-sent events (SSE).

Request

{
  "provider": "openai" | "anthropic" | "custom",
  "model": "provider model ID",
  "messages": [{ "role": "user", "content": "Hello" }],
  "max_tokens": 1000,
  "temperature": 0.7
}

Guards

  • Gateway-key or Supabase-JWT authentication.
  • Tenant-active and subscription-status check before an upstream call.
  • Configured model allowlist, request limits, rate check, and estimated monthly budget reservation.
  • Prompt and response bodies are proxied but not stored in Gatekeeper usage logs.

A 402 response indicates an inactive subscription or budget threshold reached. A 429 indicates a rate limit; a 503 can indicate an unavailable budget check. Costs are estimates, and provider charges remain your responsibility. Rate checks fail open during an Upstash outage.