AiSecurityCustomTopics
Source:
src/Cloudflare/AiSecurity/CustomTopics.ts
Custom topic categories for AI Security for Apps (Firewall for AI)
content detection on a Cloudflare zone
(/zones/{zone_id}/ai-security/custom-topics).
The topic list is a zone singleton — it always exists (defaulting to empty) and is never created or deleted, only replaced wholesale via PUT. Reconcile PUTs the desired list when the observed list differs; destroy restores the list the zone had before Alchemy first managed it.
Declare at most one AiSecurityCustomTopics per zone — two instances
managing the same zone would fight over the single underlying list.
AI Security for Apps is entitlement-gated: on accounts without the
feature every call fails with the typed AiSecurityNotEntitled error
(Cloudflare error code 13101).
Managing custom topics
Section titled “Managing custom topics”Classify traffic into two custom topics
const topics = yield* Cloudflare.AiSecurityCustomTopics("Topics", { zoneId: zone.zoneId, topics: [ { label: "billing", topic: "Questions about invoices and payments" }, { label: "abuse", topic: "Harassment or abusive language" }, ],});Clear all custom topics
yield* Cloudflare.AiSecurityCustomTopics("Topics", { zoneId: zone.zoneId, topics: [],});