{
  "openapi": "3.0.3",
  "info": {
    "title": "Diagram, Math & Code Render API",
    "version": "0.1.0",
    "description": "Callable Labs public endpoint reference. Obtain the base URL and credentials from the marketplace listing. Availability can differ by marketplace."
  },
  "paths": {
    "/v1/render/diagram": {
      "post": {
        "tags": [
          "Render diagrams"
        ],
        "summary": "Render Mermaid, Graphviz, D2 or Vega-Lite",
        "description": "Turn diagram-as-code into SVG, PNG, PDF, JPEG, WebP or a JSON PNG data URI.\nChoose `mermaid`, `graphviz`, `d2` or `vegalite`; syntax failures return a\nstructured error with the source line (and column when the engine reports it).\n\nSVG is the fastest vector output and has no pixel ceiling. Raster and PDF\noutputs are bounded by the published size limits. Vega-Lite data must be\ninline, and remote/file-reading features are blocked.\n\n**More examples**\n\n*Graphviz architecture*\n\n```json\n{\n  \"engine\": \"graphviz\",\n  \"source\": \"digraph G { rankdir=LR; client -> gateway -> renderer; renderer -> cache; }\",\n  \"layout\": \"dot\",\n  \"format\": \"png\",\n  \"width\": 1200,\n  \"background\": \"#ffffff\"\n}\n```\n\n*D2 sequence*\n\n```json\n{\n  \"engine\": \"d2\",\n  \"source\": \"client -> gateway: request\\ngateway -> renderer: render\\nrenderer -> client: image\",\n  \"layout\": \"dagre\",\n  \"format\": \"svg\"\n}\n```\n\n*Vega-Lite chart*\n\n```json\n{\n  \"engine\": \"vegalite\",\n  \"source\": \"{\\\"data\\\":{\\\"values\\\":[{\\\"month\\\":\\\"Jan\\\",\\\"sales\\\":28},{\\\"month\\\":\\\"Feb\\\",\\\"sales\\\":55},{\\\"month\\\":\\\"Mar\\\",\\\"sales\\\":43}]},\\\"mark\\\":\\\"bar\\\",\\\"encoding\\\":{\\\"x\\\":{\\\"field\\\":\\\"month\\\",\\\"type\\\":\\\"nominal\\\"},\\\"y\\\":{\\\"field\\\":\\\"sales\\\",\\\"type\\\":\\\"quantitative\\\"}}}\",\n  \"format\": \"png\",\n  \"width\": 800\n}\n```",
        "operationId": "Render diagram",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagramRequest"
              },
              "example": {
                "engine": "mermaid",
                "source": "flowchart LR\n  A[Idea] --> B{Ready?}\n  B -->|Yes| C[Ship]\n  B -->|No| A",
                "format": "svg",
                "theme": "neutral"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rendered output",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string"
                    },
                    "media_type": {
                      "type": "string"
                    },
                    "width": {
                      "type": "integer"
                    },
                    "height": {
                      "type": "integer"
                    },
                    "data_uri": {
                      "type": "string"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "engine": {
                      "type": "string"
                    },
                    "engine_version": {
                      "type": "string"
                    },
                    "cache": {
                      "type": "string",
                      "enum": [
                        "hit",
                        "miss"
                      ]
                    },
                    "render_ms": {
                      "type": "integer"
                    },
                    "queued_ms": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "format": "png",
                  "media_type": "image/png",
                  "width": 323,
                  "height": 89,
                  "data_uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…",
                  "warnings": [],
                  "engine": "graphviz",
                  "engine_version": "16.1.0",
                  "cache": "miss",
                  "render_ms": 94,
                  "queued_ms": 0
                }
              },
              "image/svg+xml": {},
              "image/png": {},
              "image/jpeg": {},
              "image/webp": {},
              "application/pdf": {}
            }
          },
          "401": {
            "description": "Authentication failed. Verify the RapidAPI subscription and generated request headers."
          },
          "403": {
            "description": "Refused by the gateway: the plan excludes this format or feature (`plan_excludes_feature`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds the configured gateway or endpoint limit."
          },
          "422": {
            "description": "Rejected before or during rendering. `invalid_request`: a field failed the schema (source too long, `scale`/`width`/`font_size` out of range, `title` too long) — `errors[].loc` names it. `bad_source`: empty source, output above the pixel ceiling, unknown theme/layout/language, more than 2000 code lines. `syntax_error`: the engine could not parse the source — `errors[].line` (and `column` where the engine reports it) says where.",
            "content": {
              "application/json": {
                "examples": {
                  "invalid_request": {
                    "value": {
                      "detail": {
                        "code": "invalid_request",
                        "message": "body.scale: Input should be less than or equal to 4",
                        "errors": [
                          {
                            "loc": "body.scale",
                            "message": "Input should be less than or equal to 4",
                            "type": "less_than_equal"
                          }
                        ]
                      }
                    }
                  },
                  "bad_source": {
                    "value": {
                      "detail": {
                        "code": "bad_source",
                        "engine": "code",
                        "message": "output would be 220×42064px; the limit is 8192×8192px (svg has no pixel limit)"
                      }
                    }
                  },
                  "syntax_error": {
                    "value": {
                      "detail": {
                        "code": "syntax_error",
                        "engine": "graphviz",
                        "message": "syntax error in line 2 near '}'",
                        "errors": [
                          {
                            "line": 2,
                            "message": "syntax error in line 2 near '}'"
                          }
                        ]
                      }
                    }
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The subscriber's rate limit or monthly request allowance was exceeded."
          },
          "502": {
            "description": "The origin service is temporarily unavailable."
          },
          "503": {
            "description": "`busy`: the node's render queue or raster memory budget is full — honour `Retry-After` (seconds) and resend. `engine_unavailable`: the engine's binary or browser is missing or restarting on this node. Both carry `Retry-After`.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            },
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "busy",
                    "engine": "mermaid",
                    "message": "64 renders are already queued on this node; retry shortly"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "504": {
            "description": "`render_timeout`: the engine exceeded its budget (graphviz 10 s, d2 15 s, mermaid 15 s, vegalite 10 s, math 5 s, code 5 s, pdf 15 s). Simplify the source or reduce the scale.",
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "render_timeout",
                    "engine": "mermaid",
                    "message": "mermaid did not finish within 15s; simplify the source or reduce the scale"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/render/math": {
      "post": {
        "tags": [
          "Render math"
        ],
        "summary": "Render a LaTeX expression",
        "description": "Render TeX with MathJax to vector paths, so the result needs no fonts on the caller. Choose display or inline style, colour, font size and output format.\n\n**More examples**\n\n*Integral as PNG*\n\n```json\n{\n  \"tex\": \"\\\\int_0^\\\\infty e^{-x^2}\\\\,dx = \\\\frac{\\\\sqrt{\\\\pi}}{2}\",\n  \"format\": \"png\",\n  \"scale\": 2,\n  \"background\": \"transparent\"\n}\n```",
        "operationId": "Render LaTeX math",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MathRequest"
              },
              "example": {
                "tex": "x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}",
                "format": "svg",
                "display": true,
                "color": "#1d4ed8",
                "font_size": 24
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rendered output",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string"
                    },
                    "media_type": {
                      "type": "string"
                    },
                    "width": {
                      "type": "integer"
                    },
                    "height": {
                      "type": "integer"
                    },
                    "data_uri": {
                      "type": "string"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "engine": {
                      "type": "string"
                    },
                    "engine_version": {
                      "type": "string"
                    },
                    "cache": {
                      "type": "string",
                      "enum": [
                        "hit",
                        "miss"
                      ]
                    },
                    "render_ms": {
                      "type": "integer"
                    },
                    "queued_ms": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "format": "png",
                  "media_type": "image/png",
                  "width": 323,
                  "height": 89,
                  "data_uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…",
                  "warnings": [],
                  "engine": "graphviz",
                  "engine_version": "16.1.0",
                  "cache": "miss",
                  "render_ms": 94,
                  "queued_ms": 0
                }
              },
              "image/svg+xml": {},
              "image/png": {},
              "image/jpeg": {},
              "image/webp": {},
              "application/pdf": {}
            }
          },
          "401": {
            "description": "Authentication failed. Verify the RapidAPI subscription and generated request headers."
          },
          "403": {
            "description": "Refused by the gateway: the plan excludes this format or feature (`plan_excludes_feature`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds the configured gateway or endpoint limit."
          },
          "422": {
            "description": "Rejected before or during rendering. `invalid_request`: a field failed the schema (source too long, `scale`/`width`/`font_size` out of range, `title` too long) — `errors[].loc` names it. `bad_source`: empty source, output above the pixel ceiling, unknown theme/layout/language, more than 2000 code lines. `syntax_error`: the engine could not parse the source — `errors[].line` (and `column` where the engine reports it) says where.",
            "content": {
              "application/json": {
                "examples": {
                  "invalid_request": {
                    "value": {
                      "detail": {
                        "code": "invalid_request",
                        "message": "body.scale: Input should be less than or equal to 4",
                        "errors": [
                          {
                            "loc": "body.scale",
                            "message": "Input should be less than or equal to 4",
                            "type": "less_than_equal"
                          }
                        ]
                      }
                    }
                  },
                  "bad_source": {
                    "value": {
                      "detail": {
                        "code": "bad_source",
                        "engine": "code",
                        "message": "output would be 220×42064px; the limit is 8192×8192px (svg has no pixel limit)"
                      }
                    }
                  },
                  "syntax_error": {
                    "value": {
                      "detail": {
                        "code": "syntax_error",
                        "engine": "graphviz",
                        "message": "syntax error in line 2 near '}'",
                        "errors": [
                          {
                            "line": 2,
                            "message": "syntax error in line 2 near '}'"
                          }
                        ]
                      }
                    }
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The subscriber's rate limit or monthly request allowance was exceeded."
          },
          "502": {
            "description": "The origin service is temporarily unavailable."
          },
          "503": {
            "description": "`busy`: the node's render queue or raster memory budget is full — honour `Retry-After` (seconds) and resend. `engine_unavailable`: the engine's binary or browser is missing or restarting on this node. Both carry `Retry-After`.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            },
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "busy",
                    "engine": "mermaid",
                    "message": "64 renders are already queued on this node; retry shortly"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "504": {
            "description": "`render_timeout`: the engine exceeded its budget (graphviz 10 s, d2 15 s, mermaid 15 s, vegalite 10 s, math 5 s, code 5 s, pdf 15 s). Simplify the source or reduce the scale.",
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "render_timeout",
                    "engine": "mermaid",
                    "message": "mermaid did not finish within 15s; simplify the source or reduce the scale"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/render/code": {
      "post": {
        "tags": [
          "Render code"
        ],
        "summary": "Render a code screenshot",
        "description": "Turn source code into a syntax-highlighted image with Pygments. Auto-detect the language or provide it, choose a theme, and add line numbers, window chrome and a filename. SVG is recommended for long listings.\n\n**More examples**\n\n*JavaScript SVG*\n\n```json\n{\n  \"source\": \"const greet = (name) => `Hello, ${name}!`;\\nconsole.log(greet('Ada'));\",\n  \"language\": \"javascript\",\n  \"theme\": \"dracula\",\n  \"format\": \"svg\",\n  \"line_numbers\": true\n}\n```",
        "operationId": "Render source code",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeRequest"
              },
              "example": {
                "source": "def greet(name):\n    return f\"Hello, {name}!\"\n\nprint(greet(\"Ada\"))",
                "language": "python",
                "theme": "monokai",
                "format": "png",
                "line_numbers": true,
                "window": true,
                "title": "example.py"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rendered output",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string"
                    },
                    "media_type": {
                      "type": "string"
                    },
                    "width": {
                      "type": "integer"
                    },
                    "height": {
                      "type": "integer"
                    },
                    "data_uri": {
                      "type": "string"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "engine": {
                      "type": "string"
                    },
                    "engine_version": {
                      "type": "string"
                    },
                    "cache": {
                      "type": "string",
                      "enum": [
                        "hit",
                        "miss"
                      ]
                    },
                    "render_ms": {
                      "type": "integer"
                    },
                    "queued_ms": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "format": "png",
                  "media_type": "image/png",
                  "width": 323,
                  "height": 89,
                  "data_uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…",
                  "warnings": [],
                  "engine": "graphviz",
                  "engine_version": "16.1.0",
                  "cache": "miss",
                  "render_ms": 94,
                  "queued_ms": 0
                }
              },
              "image/svg+xml": {},
              "image/png": {},
              "image/jpeg": {},
              "image/webp": {},
              "application/pdf": {}
            }
          },
          "401": {
            "description": "Authentication failed. Verify the RapidAPI subscription and generated request headers."
          },
          "403": {
            "description": "Refused by the gateway: the plan excludes this format or feature (`plan_excludes_feature`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds the configured gateway or endpoint limit."
          },
          "422": {
            "description": "Rejected before or during rendering. `invalid_request`: a field failed the schema (source too long, `scale`/`width`/`font_size` out of range, `title` too long) — `errors[].loc` names it. `bad_source`: empty source, output above the pixel ceiling, unknown theme/layout/language, more than 2000 code lines. `syntax_error`: the engine could not parse the source — `errors[].line` (and `column` where the engine reports it) says where.",
            "content": {
              "application/json": {
                "examples": {
                  "invalid_request": {
                    "value": {
                      "detail": {
                        "code": "invalid_request",
                        "message": "body.scale: Input should be less than or equal to 4",
                        "errors": [
                          {
                            "loc": "body.scale",
                            "message": "Input should be less than or equal to 4",
                            "type": "less_than_equal"
                          }
                        ]
                      }
                    }
                  },
                  "bad_source": {
                    "value": {
                      "detail": {
                        "code": "bad_source",
                        "engine": "code",
                        "message": "output would be 220×42064px; the limit is 8192×8192px (svg has no pixel limit)"
                      }
                    }
                  },
                  "syntax_error": {
                    "value": {
                      "detail": {
                        "code": "syntax_error",
                        "engine": "graphviz",
                        "message": "syntax error in line 2 near '}'",
                        "errors": [
                          {
                            "line": 2,
                            "message": "syntax error in line 2 near '}'"
                          }
                        ]
                      }
                    }
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "The subscriber's rate limit or monthly request allowance was exceeded."
          },
          "502": {
            "description": "The origin service is temporarily unavailable."
          },
          "503": {
            "description": "`busy`: the node's render queue or raster memory budget is full — honour `Retry-After` (seconds) and resend. `engine_unavailable`: the engine's binary or browser is missing or restarting on this node. Both carry `Retry-After`.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            },
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "busy",
                    "engine": "mermaid",
                    "message": "64 renders are already queued on this node; retry shortly"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "504": {
            "description": "`render_timeout`: the engine exceeded its budget (graphviz 10 s, d2 15 s, mermaid 15 s, vegalite 10 s, math 5 s, code 5 s, pdf 15 s). Simplify the source or reduce the scale.",
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "render_timeout",
                    "engine": "mermaid",
                    "message": "mermaid did not finish within 15s; simplify the source or reduce the scale"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DiagramRequest": {
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "svg",
              "png",
              "pdf",
              "jpeg",
              "webp"
            ],
            "title": "Format",
            "description": "Output format. `json` returns a PNG data URI plus metadata and is the default; `svg`/`png`/`pdf`/`jpeg`/`webp` return the bytes.",
            "default": "json",
            "example": "svg"
          },
          "scale": {
            "type": "number",
            "maximum": 4,
            "minimum": 0.5,
            "title": "Scale",
            "description": "Zoom the output 0.5–4×. Ignored when `width` is set. Raster and PDF output is capped at 8192×8192 px on the hosted plans (WebP 4096×4096); SVG has no ceiling.",
            "default": 1,
            "example": 2
          },
          "width": {
            "type": "integer",
            "maximum": 4096,
            "minimum": 16,
            "nullable": true,
            "title": "Width",
            "description": "Target width in pixels (16–4096); height follows the aspect ratio and must stay within the same pixel ceiling. Overrides `scale`.",
            "example": 1024
          },
          "background": {
            "type": "string",
            "nullable": true,
            "title": "Background",
            "description": "Background colour as `#rrggbb`/`#rgb`, a CSS name, or `transparent` for none.",
            "example": "#ffffff"
          },
          "engine": {
            "type": "string",
            "enum": [
              "mermaid",
              "graphviz",
              "d2",
              "vegalite"
            ],
            "title": "Engine",
            "description": "Diagram engine: `mermaid`, `graphviz`, `d2` or `vegalite` (Vega-Lite JSON spec).",
            "example": "mermaid"
          },
          "source": {
            "type": "string",
            "maxLength": 65536,
            "minLength": 1,
            "title": "Source",
            "description": "Diagram source: Mermaid text, DOT, D2 or a Vega-Lite JSON spec. ≤ 64 KiB via POST, ≤ 8 KiB via GET. Vega-Lite specs must inline their data (`url` is refused); Graphviz attributes that read local files (`image=`, `shapefile=`, …) are refused.",
            "example": "graph TD; A[Start] --> B{Ready?}; B -->|yes| C[Ship]; B -->|no| A;"
          },
          "theme": {
            "type": "string",
            "nullable": true,
            "title": "Theme",
            "description": "Engine-specific theme. Mermaid: `default|base|dark|forest|neutral`. D2: a numeric theme id — `0` (neutral default), `1`, `3`, `4`, `5`, `8`, `101`, `200` (dark), `300`, `301`. Vega-Lite: `default|dark`. Graphviz ignores it.",
            "example": "dark"
          },
          "layout": {
            "type": "string",
            "nullable": true,
            "title": "Layout",
            "description": "Graphviz layout (`dot|neato|fdp|sfdp|circo|twopi`) or D2 layout (`dagre|elk`). Mermaid and Vega-Lite ignore it.",
            "example": "dot"
          }
        },
        "type": "object",
        "required": [
          "engine",
          "source"
        ],
        "title": "DiagramRequest",
        "description": "Render diagram-as-code source to an image."
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "detail"
        ],
        "properties": {
          "detail": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable failure code"
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation"
              },
              "errors": {
                "type": "array",
                "description": "Per-field or per-line detail when there is more than one thing to fix",
                "items": {
                  "type": "object",
                  "properties": {
                    "loc": {
                      "type": "string",
                      "description": "Field path, e.g. `body.scale`"
                    },
                    "line": {
                      "type": "integer"
                    },
                    "column": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "additionalProperties": true
          }
        }
      },
      "MathRequest": {
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "svg",
              "png",
              "pdf",
              "jpeg",
              "webp"
            ],
            "title": "Format",
            "description": "Output format. `json` returns a PNG data URI plus metadata and is the default; `svg`/`png`/`pdf`/`jpeg`/`webp` return the bytes.",
            "default": "json",
            "example": "svg"
          },
          "scale": {
            "type": "number",
            "maximum": 4,
            "minimum": 0.5,
            "title": "Scale",
            "description": "Zoom the output 0.5–4×. Ignored when `width` is set. Raster and PDF output is capped at 8192×8192 px on the hosted plans (WebP 4096×4096); SVG has no ceiling.",
            "default": 1,
            "example": 2
          },
          "width": {
            "type": "integer",
            "maximum": 4096,
            "minimum": 16,
            "nullable": true,
            "title": "Width",
            "description": "Target width in pixels (16–4096); height follows the aspect ratio and must stay within the same pixel ceiling. Overrides `scale`.",
            "example": 1024
          },
          "background": {
            "type": "string",
            "nullable": true,
            "title": "Background",
            "description": "Background colour as `#rrggbb`/`#rgb`, a CSS name, or `transparent` for none.",
            "example": "#ffffff"
          },
          "tex": {
            "type": "string",
            "maxLength": 65536,
            "minLength": 1,
            "title": "Tex",
            "description": "TeX source, e.g. `\\frac{a}{b}` or `\\int_0^\\infty e^{-x}\\,dx`. ≤ 64 KiB via POST, ≤ 8 KiB via GET.",
            "example": "\\frac{a}{b}"
          },
          "display": {
            "type": "boolean",
            "title": "Display",
            "description": "Display style (centred, larger) vs inline style.",
            "default": true
          },
          "color": {
            "type": "string",
            "nullable": true,
            "title": "Color",
            "description": "Text colour as `#rrggbb`/`#rgb`.",
            "example": "#1d4ed8"
          },
          "font_size": {
            "type": "integer",
            "maximum": 96,
            "minimum": 6,
            "title": "Font Size",
            "description": "Font size in pixels (6–96).",
            "default": 16,
            "example": 20
          }
        },
        "type": "object",
        "required": [
          "tex"
        ],
        "title": "MathRequest",
        "description": "Render a TeX expression with MathJax (SVG paths, no fonts required)."
      },
      "CodeRequest": {
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "svg",
              "png",
              "pdf",
              "jpeg",
              "webp"
            ],
            "title": "Format",
            "description": "Output format. `json` returns a PNG data URI plus metadata and is the default; `svg`/`png`/`pdf`/`jpeg`/`webp` return the bytes.",
            "default": "json",
            "example": "svg"
          },
          "scale": {
            "type": "number",
            "maximum": 4,
            "minimum": 0.5,
            "title": "Scale",
            "description": "Zoom the output 0.5–4×. Ignored when `width` is set. Raster and PDF output is capped at 8192×8192 px on the hosted plans (WebP 4096×4096); SVG has no ceiling.",
            "default": 1,
            "example": 2
          },
          "width": {
            "type": "integer",
            "maximum": 4096,
            "minimum": 16,
            "nullable": true,
            "title": "Width",
            "description": "Target width in pixels (16–4096); height follows the aspect ratio and must stay within the same pixel ceiling. Overrides `scale`.",
            "example": 1024
          },
          "background": {
            "type": "string",
            "nullable": true,
            "title": "Background",
            "description": "Background colour as `#rrggbb`/`#rgb`, a CSS name, or `transparent` for none.",
            "example": "#ffffff"
          },
          "source": {
            "type": "string",
            "maxLength": 65536,
            "minLength": 1,
            "title": "Source",
            "description": "Source code. ≤ 64 KiB via POST, ≤ 8 KiB via GET, ≤ 2000 lines. Long listings fit as `format=svg` (no pixel ceiling); raster output is limited to 8192×8192 px (~380 lines at 1×).",
            "example": "def add(a, b):\n    return a + b"
          },
          "language": {
            "type": "string",
            "maxLength": 64,
            "nullable": true,
            "title": "Language",
            "description": "Pygments language name, e.g. `python`; auto-detected when omitted.",
            "example": "python"
          },
          "theme": {
            "type": "string",
            "title": "Theme",
            "description": "Pygments style name. Curated: `default`, `friendly`, `monokai`, `dracula`, `github-dark`, `solarized-dark`, `solarized-light`, `nord`, `one-dark`, `gruvbox-dark`; any other Pygments style name is accepted too.",
            "default": "default",
            "example": "monokai"
          },
          "line_numbers": {
            "type": "boolean",
            "title": "Line Numbers",
            "description": "Print a line-number gutter.",
            "default": false
          },
          "window": {
            "type": "boolean",
            "title": "Window",
            "description": "Draw a macOS-style window title bar.",
            "default": false
          },
          "title": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "title": "Title",
            "description": "Filename shown in the window bar (implies `window`).",
            "example": "app.py"
          }
        },
        "type": "object",
        "required": [
          "source"
        ],
        "title": "CodeRequest",
        "description": "Render source code with Pygments highlighting."
      }
    }
  }
}
