Enable AI assistance to generate and edit Mermaid diagrams using natural language.
Server endpoint: POST /api/ai/assist (requires valid CSRF token). UI handles CSRF automatically.
-
API Key:
- Environment Variable (Recommended): Set
AI_API_KEY=sk-...in.envor Docker env. When set, the key is read-only in the UI. - UI Setup: Go to Settings → AI, paste your key, and click Save. Keys are stored locally in the database.
- Environment Variable (Recommended): Set
-
Providers:
- OpenAI: Default. Model:
gpt-4o-mini. - Gemini: Model:
gemini-3.1-flash-lite-preview(override withGEMINI_MODEL). - Auto-detect: Chooses provider from key prefix (
sk-...vsAIza.../gsk_...).
- OpenAI: Default. Model:
Open the AI helper panel in the editor and enter a prompt.
- Create: "Sequence diagram for user login flow"
- Edit: "Add an error state after validation"
- Specify diagram type if ambiguous: "Flowchart for..."
- Keep prompts simple and iterative.
- Do not paste sensitive data/secrets into prompts.
- AI Key Not Configured: Set
AI_API_KEYor configure in Settings. - Request Failed: provider error, network issue, or missing CSRF token (ensure browser loads the app to set the CSRF cookie).
- Mermaid Validation Failed: AI generated invalid syntax. Try a simpler prompt.
POST /api/ai/assist
- Headers:
x-csrf-tokenfrom app cookie (handled automatically by UI) - Payload:
{ "prompt": "...", "diagramId": "...", "content": "..." }
- Settings - AI API key configuration
- API Guide - REST API documentation
- Container Startup - Docker deployment guide