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.

POST/api/ai/generate

Generate a complete email from a natural language prompt.

Parameters

NameTypeDescription
prompt*stringDescription of the email you want to generate
tonestringDesired tone (e.g. professional, friendly, casual, urgent)
lengthstringDesired length (short, medium, long)

Request

json
{
  "prompt": "Welcome email for new SaaS trial users, highlighting the 3 key features",
  "tone": "friendly",
  "length": "medium"
}

Response

json
{
  "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.

POST/api/ai/improve

Improve an existing email draft based on a specific instruction.

Parameters

NameTypeDescription
html_body*stringThe current HTML email content to improve
instruction*stringWhat to improve (e.g. 'make it shorter', 'add urgency')

Request

json
{
  "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

json
{
  "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
# .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.