> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diagram.eoeok.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create diagrams with AI

> Choose a diagram type, write an effective prompt, and refine the result with AI.

DiagramAI can create a new diagram or modify the diagram currently open in the editor. In both cases, describe the structure you want rather than only the visual style.

## Choose a diagram type

Use **Auto** when the structure makes the intended format clear. Select a type when you need a specific notation.

| Type         | Include in your prompt                                            |
| ------------ | ----------------------------------------------------------------- |
| Flowchart    | Start and end points, steps, decisions, and branch outcomes       |
| Architecture | Systems, services, storage, external dependencies, and data flows |
| Sequence     | Participants, message order, responses, and alternative paths     |
| ER           | Entities, important fields, keys, and relationship cardinality    |
| Mind map     | Central topic, main branches, and nested ideas                    |
| Topology     | Regions, networks, nodes, links, and boundaries                   |

## Structure your prompt

A useful prompt usually contains:

1. The diagram type and purpose
2. The components or participants
3. The order or relationships
4. Important branches, boundaries, or exceptions
5. Labels that must appear

```text theme={null}
Create an architecture diagram for a multi-tenant SaaS application.
Include a web client, API gateway, authentication service, application service,
PostgreSQL database, Redis cache, object storage, and background worker.
Show the trust boundary between the public internet and the private network.
Label synchronous requests and asynchronous jobs.
```

<Tip>
  Use product and domain names consistently. Explicit names produce more useful labels than phrases
  such as “the service” or “the database.”
</Tip>

## Create a new diagram

<Steps>
  <Step title="Choose the destination">
    Open the folder where the diagram should be stored, or stay at the workspace root.
  </Step>

  <Step title="Open AI generation">
    Select **AI generate**, choose a diagram type, and enter your prompt.
  </Step>

  <Step title="Submit and review">
    Submit the request. DiagramAI validates the generated draw\.io document, creates a file, and
    opens the editor.
  </Step>
</Steps>

## Modify the current diagram

Open the AI panel inside the editor and describe the change in relation to the existing diagram.

```text theme={null}
Keep the current layout. Add a retry queue after the payment service,
then connect failed payment events to the queue and back to the payment worker.
```

DiagramAI reads the current diagram before applying the request. If generation fails or the returned document is invalid, the canvas is not replaced.

## Credit usage

* DiagramAI estimates whether your balance is sufficient before sending a request.
* A successful request consumes credits based on its actual token usage.
* A failed request does not consume credits.
* AI requests in a personal workspace use your personal balance.
* AI requests in a team workspace use the organization's shared balance.

See [Plans, credits, and billing](/en/plans-and-credits) for included balances and purchase rules.

<Warning>
  AI output can be incomplete or inaccurate. Review a diagram before relying on it for
  implementation, operations, security, or other important decisions.
</Warning>
