Skip to main content

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 Github Repo.

License

MIT

Metadata

Release files for diagramdsl 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diagramdsl 3.0.1
File Size Uploaded
diagramdsl-3.0.1.tar.gz 33.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diagramdsl 3.0.1
File Interpreter ABI Platform
diagramdsl-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 73.2 kB

Release files / diagramdsl-3.0.1.tar.gz

Download URL diagramdsl-3.0.1.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5ec4a9f7e7b477f3d58bc9849c76b4dba3f0a3337c3681b1ccf9141718b975f5
BLAKE2b-256 checksum
How to use checksums
53c3e97c47231349ec886b03b3d3a4ee106e3be68018b90f358a54b6edf29833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / diagramdsl-3.0.1-py3-none-any.whl

Download URL diagramdsl-3.0.1-py3-none-any.whl
Size 39.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4372f519e0168895c01e42b7c207656ca6ea37f6e9c54d02a8ee74daf56d6937
BLAKE2b-256 checksum
How to use checksums
ec19a4fa207204e63d08c9380ba440892e4b1b81acbe6d34d9cb6d4ec1b07c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page