---
title: "AI setup, MailKaro Docs"
description: "AI setup in MailKaro: turn on the AI assistant with your provider. For React, Vue, Angular and plain JavaScript."
---

# AI setup

AI & MCP

# AI setup

Turn on the AI assistant with your provider.

Configure a provider key on your backend (OpenAI / Anthropic / Gemini) and route AI through [email-craft-sdk](https://mailkaro.com/docs/ai-providers), or pass a first-party adapter for prototyping. The assistant then appears in the toolbar.

## Turn it on with the backend package

With `Mailkaro.fromEnv()` from `email-craft-sdk`, one env variable turns AI on: `OPEN_AI_KEY` or `MAILKARO_AI_KEY` for OpenAI (default model `gpt-4o-mini`), or `CLAUDE_AI_KEY` for Anthropic. `MAILKARO_AI_MODEL` picks another model. The key stays on your server; the runtime only tells the editor that AI is available.

ts

```
// next to your GET /mailkaro/embed-runtime route
router.post("/ai", async (req, res) => {
 const { method, input } = req.body;
 try {
 res.json(await mailkaro.ai(method, input));
 } catch (err) {
 res.status(500).json({ error: String(err) });
 }
});
```

## How the editor finds the route

When the runtime reports the `ai` capability, the editor posts `{ method, input }` to the `ai` route in the same folder as your `runtimeUrl`, so `/mailkaro/embed-runtime` leads to `/mailkaro/ai`. Your page makes the request, only to routes in that folder, and sends your `connectorHeaders` with it.

The built-in handler supports `rewriteText`, `generateSubjectLines`, `generateAltText`, `generateDesignFromPrompt`, `importDesign` and `editDesign` (the chat assistant). Other methods throw an error. The full route list is on the [backend](https://mailkaro.com/docs/backend) page.

Source: https://docs.mailkaro.com/ai-setup
