---
title: "Generate Diagram Preview"
method: POST
path: "/image/generate-diagram-preview"
tags: ["image"]
---

# Generate Diagram Preview

`POST /image/generate-diagram-preview`

Generate clean diagram previews for provided diagrams.

This endpoint is designed for ephemeral UI flows such as the
transcription preview modal and teacher exam diagram generation. It accepts
either diagram image URLs or a figure description (or both), calls
generate_diagram, and returns the rendered image alongside the generated
matplotlib code.

## Request body

- GenerateDiagramPreviewRequest
  - `image_urls` string[], nullable
  - `instructions` string, nullable
  - `exercise_content` string, nullable
  - `figure_description` string, nullable
  - `current_code` string, nullable
  - `current_diagram_url` string, nullable

## Response `200`

Successful Response

- GenerateDiagramPreviewResponse
  - `status` string, required
  - `message` string, required
  - `diagrams` DiagramPreviewItem[], required
    - `original_url` string, required
    - `diagram_image_url` string, required
    - `diagram_code` string, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/excellence-ai/apis/excellence-learning.md) · [All operations](https://skmtc.dev/excellence-ai/apis/excellence-learning/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/excellence-ai/excellence-learning/revisions/437cd8414e9e/schema)
