Step-based diagram renderer for AI agents — Python server and client.
Project description
diagramdsl
Step-based diagram renderer for AI agents — Python server and client.
DiagramDSL lets AI agents construct diagrams incrementally by emitting structured JSON. The Python package wraps the JavaScript renderer in a Playwright-powered headless server, exposing two HTTP endpoints that any agent or application can call.
Install
pip install diagramdsl
playwright install chromium
Quickstart
1. Generate an auth token
diagramdsl token
# f47ac10b-58cc-4372-a567-0e02b2c3d479
Store it in an environment variable:
export DIAGRAMDSL_AUTH_TOKEN=f47ac10b-58cc-4372-a567-0e02b2c3d479
2. Start the server
import os
from diagramdsl import DiagramDSLServer
server = DiagramDSLServer(
port=8421,
host="127.0.0.1",
auth=os.environ["DIAGRAMDSL_AUTH_TOKEN"],
)
server.start()
Or via CLI:
diagramdsl serve --port 8421
3. Render a diagram
import os
from diagramdsl import DiagramDSL
class FileTool(DiagramDSL):
def save(self, png_bytes: bytes) -> str:
path = "/tmp/diagram.png"
with open(path, "wb") as f:
f.write(png_bytes)
return path
tool = FileTool(host="http://localhost:8421", auth=os.environ["DIAGRAMDSL_AUTH_TOKEN"])
path = tool.render({
"1": { "node": "circle", "label": "Start", "attributes": { "background": "#fff7ed" } },
"2": { "node": "box", "label": "Process", "connect": { "from": "1", "direction": "right" } },
"3": { "node": "circle", "label": "End", "connect": { "from": "2", "direction": "right" } },
})
print(path) # /tmp/diagram.png
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/info |
DSL rules and schema — inject into agent system prompts |
POST |
/render |
Render a steps object → PNG image |
GET |
/docs/{type} |
Schema for a specific shape, edge, or direction |
GET |
/health |
Health check (no auth required) |
All endpoints except /health require Authorization: Bearer <token>.
Documentation
Full documentation at docs.diagramdsl.dev.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diagramdsl-3.0.0.tar.gz.
File metadata
- Download URL: diagramdsl-3.0.0.tar.gz
- Upload date:
- Size: 33.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ced28a59072e483e8b5505ded126b5057c607ebe0c686626294488adc388589
|
|
| MD5 |
4d29bacf1433c6c5fbfe81d69f90c196
|
|
| BLAKE2b-256 |
431b560e9d0029b6daf36f5889b73d9ae9bf85fe22adf2008399224503aec4bd
|
File details
Details for the file diagramdsl-3.0.0-py3-none-any.whl.
File metadata
- Download URL: diagramdsl-3.0.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50589cbca8ada7381b2dc1dc6f84dc1117f2ae4a38ee450b3ddc03d12df96b52
|
|
| MD5 |
f20ee615ec6b93be1f7ef6c9e06e68e7
|
|
| BLAKE2b-256 |
3e05ada30d3f9a334cfa722faafb431c84a9f673f75ff1fc14196bd55749eca7
|