AI Features
Cleanmails supports 6 LLM providers for AI auto-reply, email enhancement, and the MCP integration. Bring your own API key — no usage fees from Cleanmails.
Supported Providers
| Provider | Models |
|---|---|
| OpenAI | gpt-5.4-nano, gpt-5.4-mini, gpt-oss-20b, gpt-4.1, gpt-4.1-mini |
| Claude (Anthropic) | claude-haiku-4-5, claude-sonnet-4-6, claude-opus-4, claude-sonnet-4, claude-3-5-haiku |
| Gemini (Google) | gemini-3.1-flash-lite, gemini-3-flash-preview, gemini-2.5-flash, gemini-2.5-pro |
| Groq | llama-3.1-8b-instant, llama-4-scout-17b, gpt-oss-20b, llama-3.3-70b, qwen-qwq-32b |
| AWS Bedrock | amazon.nova-micro, amazon.nova-lite, claude-haiku-4-5, amazon.nova-pro, claude-sonnet-4 |
| OpenRouter | openrouter/free, gpt-oss-20b, llama-3.3-70b, claude-haiku-4-5, gemini-3.1-flash-lite |
Setup
- Go to Settings → AI tab
- Select your provider from the dropdown
- Enter your API key
- Select a model (each provider shows 5 options)
- Click Test Connection to verify
- Save
API keys are encrypted with AES-256-GCM before storage. They are never exposed in API responses — the dashboard only shows whether a key is configured (has_ai_key: true/false).
AI Auto-Reply
When enabled per campaign, the AI will automatically draft and send replies to inbound emails from leads:
- Triggered when a lead replies to a campaign email
- Uses the last 5 messages in the thread for context
- Respects a per-campaign AI context prompt (you define the tone, product, goals)
- Adds a human-mimicry delay (1–5 minutes) before sending
- Sends with correct threading headers (In-Reply-To, References)
- Max 3 AI replies per thread (loop prevention)
- Never replies to bounces or system emails
Enabling Auto-Reply
In the campaign builder (Step 6: Scheduler):
- Toggle AI Auto-Reply ON
- Write an AI context prompt explaining your product/service and reply guidelines
AI Email Enhancer
Rewrite email content in the campaign builder without losing personalization variables:
- Rewrite — Full rewrite maintaining intent
- Shorten — Make the email more concise
- Formal — Adjust tone to professional
- Remove Spam — Rephrase spam trigger words
The enhancer extracts {{ variables and spintax before sending to the LLM, then restores them in the output — so your personalization is preserved.
Token Budget
Each workspace has a configurable daily token cap (default: 10,000 tokens). This prevents runaway costs from AI auto-replies:
- Token usage is tracked per request (prompt + completion)
- When the cap is reached, AI features are disabled until the next daily reset
- The reset runs as a periodic background task
- Configure the cap in Settings → AI → Daily Token Cap
Settings API
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/workspaces/:wid/settings | Get AI config (provider, model, has_key, tokens_used) |
| PUT | /api/v1/workspaces/:wid/settings | Update provider, key, model, token cap |
| POST | /api/v1/workspaces/:wid/settings/test-ai | Test AI connection (sends "Say hello") |
| POST | /api/v1/workspaces/:wid/ai/enhance | Enhance/rewrite email content |
| POST | /api/v1/workspaces/:wid/ai/spam-check | Check email for 200+ spam trigger words |
For auto-reply, use a fast/cheap model (Gemini 3.1 Flash Lite, GPT-5.4-nano, or Groq Llama). For email enhancement, use a higher-quality model (GPT-4.1, Claude Sonnet 4). You can switch models anytime from Settings.