Features
AI Features
AI-powered email generation and optimization
Overview
AI-powered email generation using Claude. Write full emails from a simple prompt or improve existing drafts with targeted instructions. The AI endpoints handle subject line generation, HTML formatting, and plain text fallback creation automatically.
Requires ANTHROPIC_API_KEY in your .env.local file. Without this key, the AI features will be disabled and the endpoints will return an error.
Generate Email
Generate a complete email from a text prompt. Optionally specify the desired tone and length to control the output style. The response includes a subject line, HTML body, and plain text version.
/api/ai/generateGenerate a complete email from a natural language prompt.
Parameters
| Name | Type | Description |
|---|---|---|
prompt* | string | Description of the email you want to generate |
tone | string | Desired tone (e.g. professional, friendly, casual, urgent) |
length | string | Desired length (short, medium, long) |
Request
{
"prompt": "Welcome email for new SaaS trial users, highlighting the 3 key features",
"tone": "friendly",
"length": "medium"
}Response
{
"subject": "Welcome to Acme! Here are 3 things to try first",
"html_body": "<h1>Welcome aboard!</h1><p>We're thrilled to have you...</p>",
"text_body": "Welcome aboard! We're thrilled to have you..."
}Improve Email
Take an existing email draft and improve it based on a specific instruction. Useful for refining tone, fixing grammar, shortening content, or adding a call-to-action.
/api/ai/improveImprove an existing email draft based on a specific instruction.
Parameters
| Name | Type | Description |
|---|---|---|
html_body* | string | The current HTML email content to improve |
instruction* | string | What to improve (e.g. 'make it shorter', 'add urgency') |
Request
{
"html_body": "<h1>Hello</h1><p>Just checking in to see if you need anything.</p>",
"instruction": "Make it more engaging and add a clear call-to-action button"
}Response
{
"subject": "Quick question for you",
"html_body": "<h1>Hey there!</h1><p>We noticed you haven't explored...</p><a href='#'>Get Started Now</a>",
"text_body": "Hey there! We noticed you haven't explored..."
}Configuration
To enable AI features, add your Anthropic API key to the environment configuration. You can obtain a key from the Anthropic console.
# .env.local
ANTHROPIC_API_KEY=sk-ant-...The platform uses Claude as the underlying model for all AI operations. No additional configuration is required beyond the API key. The model selection and prompt engineering are handled internally to produce well-formatted, deliverable email content.