POST diagram source code, GET a permanent viewer url
diagram.bhk.dev stores Mermaid diagrams by content hash and returns a deterministic URL for sharing. The viewer route renders in the browser and supports source inspection plus export actions.
How it works
- POST Mermaid source to
/api/render. -
If a
402 Payment Requiredresponse is returned, satisfy the payment challenge with Model Payments Protocol (MPP) on Tempo testnet and retry. -
Receive
hash, public viewer URL, and raw source URL in the API response. -
Open
/d/{hash}to view, copy source, and export SVG or PNG.
Endpoints
/api/render /api/d/{hash} /api/d/{hash}/raw /d/{hash} Request
{
"code": "graph TD
A[Start] --> B[End]",
"type": "mermaid"
} Response
{
"hash": "a1b2c3d4e5f6a7b8",
"type": "mermaid",
"url": "https://diagram.bhk.dev/d/a1b2c3d4e5f6a7b8",
"raw": "https://diagram.bhk.dev/api/d/a1b2c3d4e5f6a7b8/raw",
"cached": false
} Fields
| Field | Type | Rules |
|---|---|---|
| code | string | required, max 50,000 chars |
| type | string | required, only mermaid for MVP |
Diagram types
Reference
Read the Swagger docs or inspect OpenAPI JSON directly.
Payment
When /api/render responds with
402 Payment Required, use an MPP-capable client like
tempo request or mppx. The
Machine Payments Protocol challenge/credential flow happens automatically, so you can retry with the
same command. Agents pay per diagram via Tempo testnet.
Need testnet funds first? For mppx, run npx mppx account fund -a testnet before sending paid requests.
If you see No key configured for network "tempo-moderato",
complete tempo wallet login --network testnet first.
For agent-focused setup guidance, see the MPP quickstart for agents.
# one-time wallet setup (required)
tempo wallet login --network testnet
tempo wallet fund --network testnet
# verify wallet is ready
tempo wallet whoami --network testnet
# optional safety guard
export TEMPO_MAX_SPEND=0.05
# inspect payment without sending request
tempo request --network testnet --dry-run \
--request POST \
--json '{"code":"graph TD; A-->B;","type":"mermaid"}' \
https://diagram.bhk.dev/api/render
# send a paid render request on testnet
tempo request --network testnet \
--request POST \
--json '{"code":"graph TD; A-->B;","type":"mermaid"}' \
https://diagram.bhk.dev/api/render # setup
npx mppx account create
npx mppx account fund -a testnet
# create a diagram
npx mppx https://diagram.bhk.dev/api/render \
--method POST \
-J '{"code":"graph TD; A-->B;","type":"mermaid"}' Current scope
Mermaid is the only supported format in the current MVP. The API is public and documentation is served from this domain.
MPP payment enforcement is enabled on /api/render using Tempo
testnet.
Links
Use /docs for interactive reference, /openapi.json for schema-aware tooling, and /api/health for basic checks.
Live viewer example: /d/33237557afdf021c.
Agent skills: diagram skill and tempo skill.
Read https://tempo.xyz/SKILL.md and https://diagram.bhk.dev/SKILL.md, then render a Mermaid diagram and return the viewer URL.