---
title: "Generate or review a diagram with the optional AI assistant (streamed)."
method: POST
path: "/ai"
tags: ["AI"]
---

# Generate or review a diagram with the optional AI assistant (streamed).

`POST /ai`

## Request

- Base URL: `https://www.livediagram.app/api`
- URL: `https://www.livediagram.app/api/ai`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-Owner-Id`

## Request body

- AiRequest
  - `elements` unknown[], required
    - unknown
  - `focusIds` string[]
  - `history` AiConversationTurn[]
    - `content` string, required
    - `role` 'user' | 'assistant', required
  - `mode` 'clean' | 'ask', required
  - `prompt` string, required
  - `tabName` string, required

## Response `200`

Success.

## Other responses

- `401`: Error.
- `403`: Error.
- `429`: Rate limited. Back off and retry.
- `500`: Error.
- `502`: Error.
- `503`: Error.

---

[API](https://skmtc.dev/livediagram/apis/livediagram-api.md) · [All operations](https://skmtc.dev/livediagram/apis/livediagram-api/llms.txt) · [OpenAPI document](https://skmtc.dev/livediagram/apis/livediagram-api/revisions/f286d27acfd2?raw)
