/v2/ai/generate-previewPersonalizes an existing HTML template against lead details and/or an AI prompt — the core AI Playground action. Pick a model from List models, or omit model to use the default.
| Authorization | Bearer YOUR_API_KEY |
| Content-Type | application/json |
| Field | Type | Required | Description |
|---|---|---|---|
| html | string | Required | The template body to personalize, 1–800,000 characters. |
| subject | string | Optional | Subject line, up to 998 characters. |
| leadDetails | object | Optional | Flat string map used for merge fields, up to 100 keys. |
| aiPrompt | object | Optional | { prompt (1–10,000 chars, required), tone?, length?, leadDetails? } — instructions for how to personalize. |
| model | string | Optional | A model id from List models, must be email-eligible (has emailCredits). Omitted, unset, or an id with no emailCredits falls back to gpt-6-sol — note this is NOT the same model as List models' top-level defaultModel field, which is the AI Agent/chat default (gpt-6-luna). |
curl -X POST "https://api.stynar.com/v2/ai/generate-preview" \
-H "Authorization: Bearer esk_your_key_here" \
-H "Content-Type: application/json" \
-d '{"html":"<p>Hi {{firstName}},</p><p>Saw {{company}} is hiring — thought you'"'"'d like this.</p>","leadDetails":{"firstName":"Jane","company":"Acme"},"aiPrompt":{"prompt":"Make the opening line reference their recent funding round.","tone":"casual"},"model":"gpt-6-luna"}'{
"html": "<p>Hi Jane,</p><p>Congrats on the Series A — thought you'd like this.</p>",
"subject": "Quick question about Acme",
"model": "gpt-6-luna",
"creditsCharged": 0.4
}| Status | Code | Meaning |
|---|---|---|
| ✕ 402 | QUOTA_EXCEEDED | Not enough credits for this model. |
| ✕ 403 Forbidden | QUOTA_EXCEEDED | The chosen model's tier is locked during your trial. |
| ✕ 401 Unauthorized | UNAUTHORIZED | Missing, malformed, unknown, revoked, or expired key. |
| ✕ 403 Forbidden | API_ACCESS_DISABLED | API access is turned off for your account. |
| ✕ 403 Forbidden | INSUFFICIENT_SCOPE | The key doesn't have the scope this endpoint requires. |
| ✕ 404 Not Found | NOT_FOUND | Unknown route, or a resource that doesn't exist / isn't yours. |
| ✕ 409 Conflict | CONFLICT | The action can't be applied to the resource's current state. |
| ✕ 429 Too Many Requests | RATE_LIMIT_EXCEEDED | Per-minute or per-second limit hit. |
| ✕ 429 Too Many Requests | QUOTA_EXCEEDED | Monthly quota exhausted. |
| ✕ 500 Internal Server Error | INTERNAL_ERROR | Something broke on Stynar's end. |