Cloudflare Worker for the Easy Email Pro AI agent. It exposes the Easy Email agent streaming API and forwards AI requests through Cloudflare AI Gateway.
- A Cloudflare account
- A Cloudflare AI Gateway configured for the OpenAI-compatible provider
- A Cloudflare API token that can call that gateway
- Node.js and pnpm
This directory is intended to be usable as a standalone project. Run the
commands below from inside the easy-email-pro-ai-worker directory.
Only two variables are required:
CLOUDFLARE_AI_GATEWAY_BASE_URL=https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/openai
CF_TOKEN=<cloudflare_api_token>Optional overrides:
AI_TEXT_MODEL=gpt-5.4-mini
AI_IMAGE_MODEL=openai/gpt-image-1-mini
AI_IMAGE_QUALITY=mediumIf the optional values are not set, the worker uses the defaults shown above.
Install dependencies:
pnpm installCopy the example environment file:
cp .env.example .envFill in CLOUDFLARE_AI_GATEWAY_BASE_URL and CF_TOKEN, then start the worker:
pnpm devThe worker exposes:
POST /v1/easy-email/respond-streamThe response is Server-Sent Events. The request body follows the Easy Email AI agent request shape used by the editor integration:
{
"prompt": {
"text": "Help me improve this email"
},
"template": {
"subject": "Test",
"content": {
"type": "page",
"children": []
}
},
"images": [],
"history": null
}The worker does not require a public API bearer token or allowed-origin list. Protect access at your deployment boundary if the endpoint should not be public.
Build and deploy with:
pnpm deployFor a dry run:
pnpm check:cfSet the required environment variables in Cloudflare before deploying. For
deployment, configure CLOUDFLARE_AI_GATEWAY_BASE_URL and CF_TOKEN in the
Cloudflare dashboard, or set them with Wrangler:
printf '%s' 'https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/openai' \
| pnpm wrangler secret put CLOUDFLARE_AI_GATEWAY_BASE_URL
printf '%s' '<cloudflare_api_token>' \
| pnpm wrangler secret put CF_TOKENDo not commit customer-specific Gateway URLs or tokens into wrangler.toml.
Run the worker tests:
pnpm test:workerRun TypeScript checks:
pnpm typecheck