Skip to main content

Enable AI Security for Apps & Label Endpoints

Introduction

In this module, you will enable AI Security for Apps and the Cloudflare Managed Ruleset, then register and label the public endpoints used by the Seven Hills AI Agent. This brings the ecommerce chat and concierge paths under Cloudflare inspection: the WAF addresses conventional web attacks, while AI Security for Apps prepares prompts for AI-specific analysis. This improves visibility to protect customer interactions without changing how shoppers access the agent.

Seven Hills uses two endpoints:

EndpointFormatPurpose
/api/chatStandard JSON: { "message": "..." }Main chat endpoint
/api/conciergeNested JSON with the prompt at $.assistant_context.shopping_request.customer_promptConcierge endpoint

Architecture Context

Browser -> Cloudflare WAF + AI Security for Apps -> Seven Hills Worker
|
+-> /api/chat -> Workers AI
+-> /api/concierge -> Workers AI

The pre-deployed app is served on your lab domain, <your-slug-lab>.sxplab.com. Its custom domain routes traffic through Cloudflare's Web services stack, so AI Security for Apps can inspect requests.

note

Configure all security settings in this exercise at the zone level, not the account level.

Steps

1. Enable AI Security for Apps

  1. Go to dash.cloudflare.com and select your lab zone.
  2. Navigate to Security > Settings.
  3. Filter by Web application exploits.
  4. Find AI Security for Apps and toggle it On.

Enable AI Security

  1. Enable the Cloudflare Managed Ruleset and keep the default ruleset action and status.

Enable web application exploits

Why enable the Managed Ruleset?

The Managed Ruleset protects against common web attacks such as SQL injection, cross-site scripting, and remote code execution. Together, the Managed Ruleset and AI Security for Apps cover conventional web exploits and AI-specific threats.

Expected Result:

  • AI Security for Apps is On.
  • The Cloudflare Managed Ruleset is Enabled.

2. Manually Add LLM Endpoints

AI Security for Apps can auto-discover LLM endpoints, but discovery can take some time. Manually create the endpoints for this lab so analysis can begin immediately.

  1. Navigate to Security > Web Assets.
  2. Select Add endpoint/operations.
  3. Add the main chat endpoint:
FieldValue
Path/api/chat
MethodPOST
Hostname<your-slug-lab>.sxplab.com
  1. Add the concierge endpoint:
FieldValue
Path/api/concierge
MethodPOST
Hostname<your-slug-lab>.sxplab.com

Web assets endpoints

3. Apply the cf-llm Label

  1. In Security > Web Assets > Endpoints, locate /api/chat.
  2. Select the Edit cog icon.

Edit endpoint label

  1. In Labels, select cf-llm.
  2. Select Save labels.

Save endpoint label

  1. Repeat these steps for /api/concierge.
note

You can also use bulk update to apply a label to multiple endpoints.

4. Verify the Labels

In Security > Web Assets, confirm that:

  • /api/chat has the cf-llm label.
  • /api/concierge has the cf-llm label.

Verify endpoint labels

What You Established

You enabled the required protections, added /api/chat and /api/concierge as web assets, applied the cf-llm label, and confirmed that both endpoints are recognized for AI analysis. Cloudflare can now inspect these customer-facing paths for AI risks while legitimate product discovery and shopping assistance continue through the existing ecommerce workflow. This establishes the foundation for the custom detections and mitigations that follow.