# Bring your own AI model to your email · cloudmail

> Choose the AI model behind your email: Workers AI in your own Cloudflare account, or your own Anthropic-compatible or OpenAI-compatible gateway, set per task.

Canonical: https://trycloudmail.com/features/bring-your-own-ai
Last updated: 2026-11-24

**Run your email's AI on the model you choose.** cloudmail's AI runs on Workers AI in your own Cloudflare account. An administrator can pick the model for each task, or route every AI feature to an Anthropic-compatible or OpenAI-compatible gateway.

## How model routing works

- **A model per task**: Choose the model for chat, drafts, summaries, triage and search separately.
- **Any compatible gateway**: Anthropic, OpenAI, OpenRouter, Groq, Gemini, Azure OpenAI, DeepSeek, Cloudflare AI Gateway, or a proxy such as LiteLLM or Ollama.
- **Tested before it is used**: Test sends a small text, JSON and tool-call request, and a model that can't do what a task needs is refused.
- **One click back**: Use built-in switches back to Workers AI, and your gateway stays saved.
- **Keys stay encrypted**: Gateway tokens are encrypted at rest and no API ever returns them.
- **Usage per provider**: The Usage tab shows calls and tokens for each provider and each task.

- [Workers AI pricing and free allowance](https://trycloudmail.com/pricing)

## From the command line

```bash
cloudmail ai status                    # where AI runs, and each task's model
cloudmail ai models list --task text
cloudmail ai route summary --reset --provider workers-ai
```

In the docs: [Bring your own AI gateway](https://github.com/cloudmail-hq/cloudmail/blob/main/docs/reference.md#bring-your-own-ai-gateway).

## Questions about AI models and gateways

### Which AI gateways work with cloudmail?

Any gateway that speaks the Anthropic Messages API or the OpenAI Chat Completions API over public HTTPS. That includes Anthropic, OpenAI, OpenRouter, Groq, Gemini's OpenAI-compatible endpoint, Azure OpenAI, DeepSeek and Cloudflare AI Gateway.

### What happens if my gateway is down?

The AI feature that called it pauses, and mail keeps arriving. Falling back to Workers AI is off unless you turn it on.

### Who can change the AI provider?

Only a signed-in administrator. An API token can list and test providers but not change them, and no MCP tool can.

## Related features

- [AI email assistant](https://trycloudmail.com/features/ai-email-assistant) - Summaries on every thread and replies drafted for you to send.
- [AI email triage](https://trycloudmail.com/features/ai-email-triage) - Labels you describe in plain words, and a Screener for first-time senders.
- [Security](https://trycloudmail.com/features/email-security) - Passkeys, two-factor sign-in, sender checks and remote images held back.

## Related

- [Features](https://trycloudmail.com/features)
- [Pricing](https://trycloudmail.com/pricing)
- [Docs](https://trycloudmail.com/docs)
