You will need a Diagrams.so account first. API keys are created in the app, so step 1 is a quick
hop to diagrams.so before you write any code.
1. Connect
Using the MCP server or an SDK? Connect once and you are done. Nothing to copy, nothing to paste:- The plaintext key is shown once at creation. Store it in a secret manager.
- Keys are prefixed
dgz_live_(production) ordgz_test_(test mode). - You can scope a key to read-only, write, or read & write, and set an expiry.
2. Confirm your key works
200 with your account, plan, and scopes means you are set. A 401 means the key is missing,
malformed, or revoked.
3. Generate a diagram
Generation is AI-backed and can take 30 seconds or more. On a plain
curl there is no progress
until it completes, so for live progress use POST /diagrams/stream.
For reference: edits and fixes typically take 10 to 20 seconds, and re-layout runs as an
async job you poll. The SDKs and MCP server default to a 180-second timeout.4. Iterate
Edit with a prompt
POST /diagrams/{id}/edit, for example “add a CloudFront distribution in front of the ALB”.Fix a warning
POST /diagrams/{id}/fix applies a recommended change.Export
GET /diagrams/{id}/export?format=svg returns draw.io or SVG.Prefer an agent?
Do all of the above from Claude or Cursor via MCP.
Prefer not to write HTTP?
Python SDK
pip install diagrams-soTypeScript SDK
npm i @diagrams-so/sdk