Skip to content

Shield public unauthenticated AI forms from bot abuse

Keep interactive landing-page demos and public lead widgets safe from scripted prompt drain using origin checks, payload caps, and Turnstile tokens.

Copy the prompt and paste it into the AI assistant you already use.

Checklist to harden public AI form endpoints

  1. 01

    Verify bot-challenge tokens

    Validate Cloudflare Turnstile or captcha tokens server-side inside APIkit before model execution.

  2. 02

    Lock prompt intent tightly

    Use strict schemas and tiny input length caps so attackers cannot repurpose your widget as free ChatGPT.

  3. 03

    Apply harsh anonymous IP limits

    Cap unauthenticated IPs to a handful of calls per hour while logged-in users get real quotas.

  4. 04

    Enable edge response caching

    Serve preset sample demos from zero-cost edge cache so casual clicks never touch model quotas.

How it works in practice

Public Widget Hardening Stack

1. Turnstile Token Verification -> required 2. Origin Lock -> https://acme.com only 3. IP Sliding Limit -> 5 runs / hour 4. Input Cap -> max 280 chars | Output -> max 120 tokens

Blocked Bot Probe vs Legitimate Visitor

Scripted curl spam -> 403 {"error":"missing_turnstile_token"} Verified browser -> 200 OK (served within 5/hr budget)

Marketing widgets stay interactive for genuine prospects while automated scripts fail at the edge at zero token cost.

Common questions

How do you stop someone curling a public widget endpoint directly?

Requiring a one-time verified challenge token alongside strict origin and IP limits blocks automated terminal scripts.

Can attackers still hijack a capped public prompt for unrelated essays?

Combining a tight 280-character input limit, strict JSON schema, and low max_tokens prevents off-task general chat abuse.

Does Turnstile verification require us to run a backend endpoint?

No. APIkit verifies the challenge token directly at the gateway before running your prompt.