Summary
When a Cloudflare Worker calling env.AI.run(...) fails with AiError: 3040 Capacity temporarily exceeded, Cannot read properties of undefined (reading 'run'), or 100001 Internal error, your AI endpoint is either missing its [ai] binding, hitting a transient model capacity limit, or timing out on a large prompt.
If you want this fixed cleanly, SazM debugs production Cloudflare Workers AI apps for a fixed $99, delivered within 48 hours, 100% in writing with zero calls. See our AI integration services or request the $99 fix.
1. Missing [ai] Binding (env.AI is undefined)
- In
wrangler.toml, ensure[ai]\nbinding = "AI"is present in both top-level and environment-specific blocks. - In
wrangler.jsonc, add"ai": { "binding": "AI" }.
2. AiError: 3040 & Rules-Only Fallbacks
Workers AI models can return 3040 Capacity temporarily exceeded or 429 under load:
- Wrap
env.AI.run(...)in a short timeout (AbortSignal.timeout(8000)), catchAiError, and fall back to a deterministic rules-based response or secondary model so the Worker never returns a 500.
Need It Fixed?
We run our own Cloudflare Workers AI intake agent and 5-tool MCP server (sazm.in/mcp) in production and fix Workers AI bugs for a fixed $99 within 48 hours, verified before you pay and 100% async. Start your $99 fix or explore our AI integration services.