Cloudflare Workers

Agent optimization at the edge. Zero origin changes.

Deploy a Cloudflare Worker in front of any origin. AI agents receive optimized content. Human visitors pass through untouched.

Edge-native

Runs on Cloudflare's global network.

The Worker runs in 300+ data centers worldwide. Agent detection happens in under 5ms at the CDN edge, before the request ever reaches your origin server.

Optimized content is cached in Cloudflare KV for near-instant response times. Human traffic is proxied to your origin with zero overhead.

Request flow
Option Description
Human browser Proxied to origin unchanged
/llms.txt Served from Inception Agents API (cached in KV)
/.well-known/agent.json Served from Inception Agents API
AI agent (GPTBot, etc.) Optimized response with JSON-LD enrichment
Integration guide

Complete setup instructions.

Every code block is complete and copy-paste-ready. Total time: ~10 minutes.

Prerequisites

  • Cloudflare account with Workers enabled
  • Node.js 18+
  • Your Inception Agents API key from the dashboard

Step 1: Install the SDK

terminal
npm install @inception-agents/cloudflare

Step 2: Create the Worker

src/index.ts
// src/index.ts
import { createInceptionHandler } from '@inception-agents/cloudflare';

export interface Env {
  INCEPTION_API_KEY: string;
  INCEPTION_CACHE: KVNamespace;
}

export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext
  ): Promise<Response> {
    const handler = createInceptionHandler({
      apiKey: env.INCEPTION_API_KEY,
      originUrl: 'https://your-origin.com',
      kvCache: env.INCEPTION_CACHE,
      kvCacheTtl: 300,
    });
    return handler(request, env, ctx);
  },
};

Step 3: Configure wrangler.toml

wrangler.toml
name = "inception-proxy"
main = "src/index.ts"
compatibility_date = "2026-02-01"

[[kv_namespaces]]
binding = "INCEPTION_CACHE"
id = "your-kv-namespace-id"

Create the KV namespace:

terminal
npx wrangler kv namespace create INCEPTION_CACHE
# Copy the ID into wrangler.toml

Step 4: Set Secrets

terminal
npx wrangler secret put INCEPTION_API_KEY
# Paste your API key when prompted

Step 5: Deploy

terminal
npx wrangler deploy

Step 6: Verify

verify.sh
# Test llms.txt
curl -s https://inception-proxy.your-subdomain.workers.dev/llms.txt

# Test agent detection
curl -s -H "User-Agent: GPTBot/1.0" https://inception-proxy.your-subdomain.workers.dev/

# Test human passthrough
curl -s https://inception-proxy.your-subdomain.workers.dev/

Detection-Only Mode

If you only need agent detection metadata without content optimization:

detection-only.ts
import { createDetectionHandler } from '@inception-agents/cloudflare';

export default {
  async fetch(
    request: Request,
    env: { INCEPTION_API_KEY: string }
  ) {
    const detect = createDetectionHandler({ apiKey: env.INCEPTION_API_KEY });
    return detect(request);
    // Returns: { isAgent: true, identity: "GPTBot", provider: "openai", ... }
  },
};
Configuration options
Option Type Default Description
apiKey string (required) Your Inception Agents API key
originUrl string Origin URL to proxy non-agent traffic
kvCache KVNamespace KV namespace for edge caching
kvCacheTtl number 300 Cache TTL in seconds
detectionThreshold number 0.7 Confidence threshold for agent detection
enableLlmsTxt boolean true Serve llms.txt files
enableJsonLd boolean true Inject JSON-LD for agent traffic
enableAgentCard boolean false Serve /.well-known/agent.json
debug boolean false Log detection events
Works with any origin

The Worker sits in front of any HTTP origin.

Your backend stays exactly as-is.

Shopify

Set originUrl to your myshopify.com URL.

WordPress

Proxy to your WordPress hosting provider.

Salesforce

Proxy to your Salesforce Commerce instance.

Custom Backend

Any server that responds to HTTP requests.

Troubleshooting

Common issues and fixes.

Worker returns 404

Ensure originUrl is set correctly in the handler config. Check that the origin is accessible from Cloudflare's network.

KV cache not working

Verify the KV namespace ID in wrangler.toml matches your namespace. Check that the binding name matches what you pass to kvCache.

No agent traffic in dashboard

Use curl with a known agent User-Agent to test detection. Check wrangler tail for real-time logs.

Ship in 10 minutes

Deploy in 10 minutes.

One Worker. Every AI agent optimized at the edge.