Prompt → Diagram (AI)

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

This endpoint generates a new AI diagram or edits an existing one from user-provided input, with support for file attachments and additional context.

Example requests

An example cURL request for generating a new diagram:

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "theme": "dark",
    "diagramType": "cloud-architecture-diagram",
    "text": "Azure Front Door routes to a web UI (App Service/Static Web Apps); requests go through API Management to Cognitive Search (indexing Blob Storage/DevOps Repos) and Azure OpenAI for answers; Functions handle transforms, Redis caches; responses return via API Management; monitored with Azure Monitor + Application Insights."
}'

An example cURL request for editing an existing diagram:

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "priorRequestId": "6ZoBxeDf94ix9IB7Fx8G",
    "text": "Add a CDN layer in front of the Azure Front Door"
}'

An example cURL request with a file attachment:

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "text": "Generate a diagram based on this screenshot",
    "attachments": [
        {
            "filename": "screenshot.png",
            "mimeType": "image/png",
            "content": "$BASE64-ENCODED-CONTENT-HERE"
        }
    ]
}'

Here's an example cURL request using a git repository:

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
  "text": "Generate an architecture diagram based on Terraform files in /wordpress-fargate/.",
  "diagramType": "cloud-architecture-diagram",
  "gitContexts": [
    {
      "orgName": "acme-corp",
      "repoName": "terraform-iac"
    }
  ]
}'

An example cURL request using a preset library (contextId can be found on the AI Presets page; docs):

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "text": "Create a mobile application architecture diagram utilizing the Payment Processing Module and Authentication Module from the ACME Corp Architecture Library.",
    "diagramType": "cloud-architecture-diagram",
    "contextId": "$CONTEXT-ID"
}'

An example cURL requesting an editable Eraser file with granular link access options:

curl --location 'https://app.eraser.io/api/render/prompt' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
  "diagramType": "cloud-architecture-diagram",
  "fileOptions": {
    "create": true,
    "linkAccess": "publicly-editable"  
  },
  "text": "3-tier web application architecture using Azure."
}'

Example responses

An example response is:

{
  "requestId": "generated-request-id",
  "imageUrl": "https://IMAGE-SITE-URL/IMAGE-NAME.png",
  "createEraserFileUrl": "https://ERASER-URL-TO-OPEN-DIAGRAM-IN-EDITOR",
  "diagrams": [
    {
      "diagramType": "cloud-architecture-diagram",
      "code": "// EXAMPLE DIAGRAM \n A > B \n B > C"
    }
  ]
}

An example response when fileOptions.create is set to true

{
  "requestId": "generated-request-id",
  "imageUrl": "https://IMAGE-SITE-URL/IMAGE-NAME.png",
  "fileUrl": "https://ERASER-URL-TO-OPEN-DIAGRAM-IN-EDITOR",
  "diagrams": [
    {
      "diagramType": "cloud-architecture-diagram",
      "code": "// EXAMPLE DIAGRAM \n A > B \n B > C"
    }
  ]
}

Full documentation of the endpoint below:

Body Params
string
required

The prompt. The input code or natural language which describes a diagram.

string
enum

Select desired diagram type. Will automatically detect diagram type when unspecified. Note: "freeform-diagram" is element-based — it cannot be edited via inlineCodeEdit (use priorRequestId instead), and its responses do not include a "code" field.

Allowed:
string
enum

Model tier. "premium" (default) uses a higher-quality model; "standard" uses a faster, lower-cost model. Defaults to "premium".

Allowed:
string

ID of a previous request to edit. When provided, the API will edit the diagram from that request.

attachments
array of objects

File attachments to provide context for diagram generation. Accepts PNG, JPEG, and PDF files.

attachments
string

ID of an AI preset to use as context for generation. Find contextId in the AI preset page (https://app.eraser.io/dashboard/ai-preset).

string

ID (workspaceId) of a template within a preset. Both contextId and templateId are required to use a template. Find ID by navigating to AI preset (https://app.eraser.io/dashboard/ai-preset) > Templates > Open a template

inlineCodeEdit
object

Edit flow without a prior AI request: pass existing canvas diagram code and type directly. Mutually exclusive with priorRequestId for the edit source.

git
object
deprecated

Deprecated. Use gitContexts instead.

gitContexts
array

Git repository contexts for diagram generation. Supports one or more repositories. Use publicRepoUrl for public repos, or repoName and orgName for private repos connected to your team.

gitContexts
boolean

When true, returns the image as a file stream instead of a URL.

boolean
deprecated

Deprecated. Use returnImageAsFile instead.

fileOptions
object

Options for creating an Eraser file immediately with granular link access settings, rather than returning a URL for manual creation.

boolean

Select transparent (false) or solid (true) background. Defaults to false.

string
enum

Select "light" or "dark" theme. Defaults to "light".

Allowed:
integer
enum

Image quality/resolution multiplier. Use 1 (low), 2 (medium), or 3 (high). Defaults to 2.

Allowed:
integer
enum
deprecated

Deprecated. Use imageQuality instead.

Allowed:
Responses

400

The request is missing required parameters or validation failed

403

Unauthorized

404

Prior request or context not found

500

Eraser was unable to generate a result

503

Service temporarily unavailable. This may be the result of too many requests.

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json