---
agentTools:
  projectIndex: https://elai.readme.io/llms.txt
---

# Rephrase or regenerate one quiz question

Takes an existing question and returns a new version of it. Stateless — nothing is persisted.

Two modes, with mutually exclusive knobs:

**`rephrase`** — improve the wording. Answer count, quiz type and the number of correct answers are preserved (though which positions are correct may move). Combine hint keys in `instructions` (e.g. `improve_clarity`, `more_professional`). `quizType` and `answersCount` are **rejected** in this mode.

**`regenerate`** — reshape the question, e.g. change type or option count via `quizType` and `answersCount` (`0` lets the model choose). Feedback text is always regenerated. `instructions` are **rejected** in this mode.

`notice` reports `insufficient_data` when the input question was underspecified; the model still runs.

```curl Request
curl -X POST 'https://apis.elai.io/api/v1/quiz/regenerate-question' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "rephrase",
  "instructions": [
    "improve_clarity"
  ],
  "shouldRegenerateFeedback": false,
  "question": {
    "questionText": "What is Elai?",
    "answers": [
      {
        "text": "A video platform"
      },
      {
        "text": "A database"
      }
    ],
    "correctAnswers": [
      0
    ]
  }
}'
```

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Elai Public API",
    "version": "1.0",
    "description": "Every endpoint below is served under `https://apis.elai.io/api/v1`.\n\n## Authentication\n\nSend your workspace API token as a bearer token on every request:\n\n```\nAuthorization: Bearer <your-api-token>\n```\n\nGenerate and rotate the token in the Elai web app under **Settings → API**, or through\n`POST /generateToken`. The token is scoped to one **workspace** and authenticates as that\nworkspace's admin user — it is not tied to an individual person, and it carries admin rights\ninside that workspace.\n\nA request with a missing, unknown or revoked token gets a bare `401` with no response body.\n\n> **Organizations on the Unlimited plan cannot use the API.** Their requests are rejected with the\n> same bare `401` as an invalid token, with nothing to distinguish the two. If a valid, freshly\n> generated token returns `401` on every endpoint, check the plan first.\n\n## Errors\n\nFailures carry a JSON body of the shape `{ \"message\": \"...\" }`. Validation failures on the newer\nendpoints may add an `errors` array naming the offending fields. `401` is the exception: it has no\nbody at all.\n\nBoth render endpoints are **fire-and-forget** — they queue work and return immediately, so a\n`200` means \"accepted\", not \"rendered\". Render failures surface only through the `video_error`\nwebhook, never as an HTTP error on the call that started the render.\n\n## Scope\n\nThis reference is generated from the running code rather than maintained by hand, so it cannot\nquietly fall behind the API it describes. It documents 96 operations across the\n`/api/v1` surface.\n\nEndpoints are grouped by subject in the sidebar. If something you need is missing, or an endpoint\ndoes not behave as described here, tell us.\n\n---\n\n_Generated from `chore/web-4760/api-v1-reference-build` at `5289745d` on 2026-09-04._"
  },
  "servers": [
    {
      "url": "https://apis.elai.io/api/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "bearer",
        "x-default": "SECRET_KEY"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the failure."
          }
        }
      },
      "ValidationErrorBody": {
        "type": "object",
        "description": "Schema-validation failure, produced by the Zod validation middleware.",
        "properties": {
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "description": "Per-field problems, when available.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "QuizQuestion": {
        "type": "object",
        "description": "A generated quiz question, ready to place on a slide. Extra canvas/theme fields round-trip unchanged.",
        "properties": {
          "questionText": {
            "type": "string"
          },
          "answers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          },
          "correctAnswers": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Indexes into `answers`."
          },
          "feedback": {
            "type": "object",
            "description": "Messages shown after answering.",
            "properties": {
              "onCorrect": {
                "type": "string"
              },
              "onWrong": {
                "type": "string"
              }
            }
          },
          "slideIds": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Slides the question was derived from."
          },
          "placeAfterSlideId": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Suggested position for the quiz slide."
          }
        },
        "additionalProperties": true
      }
    },
    "responses": {
      "LlmNotAllowed": {
        "description": "AI features are not enabled for this workspace, or its LLM usage allowance is exhausted.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/quiz/regenerate-question": {
      "post": {
        "tags": [
          "Quiz"
        ],
        "summary": "Rephrase or regenerate one quiz question",
        "description": "Takes an existing question and returns a new version of it. Stateless — nothing is persisted.\n\nTwo modes, with mutually exclusive knobs:\n\n**`rephrase`** — improve the wording. Answer count, quiz type and the number of correct answers are preserved (though which positions are correct may move). Combine hint keys in `instructions` (e.g. `improve_clarity`, `more_professional`). `quizType` and `answersCount` are **rejected** in this mode.\n\n**`regenerate`** — reshape the question, e.g. change type or option count via `quizType` and `answersCount` (`0` lets the model choose). Feedback text is always regenerated. `instructions` are **rejected** in this mode.\n\n`notice` reports `insufficient_data` when the input question was underspecified; the model still runs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "mode": "rephrase",
                "instructions": [
                  "improve_clarity"
                ],
                "shouldRegenerateFeedback": false,
                "question": {
                  "questionText": "What is Elai?",
                  "answers": [
                    {
                      "text": "A video platform"
                    },
                    {
                      "text": "A database"
                    }
                  ],
                  "correctAnswers": [
                    0
                  ]
                }
              },
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "rephrase",
                      "regenerate"
                    ]
                  },
                  "question": {
                    "type": "object",
                    "properties": {
                      "questionText": {
                        "type": "string"
                      },
                      "answers": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "text"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      "correctAnswers": {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "theme": {
                        "type": "string",
                        "enum": [
                          "light",
                          "dark",
                          "transparent_dark",
                          "transparent_light"
                        ]
                      },
                      "layout": {
                        "type": "string",
                        "enum": [
                          "vertical",
                          "horizontal"
                        ]
                      },
                      "quizType": {
                        "type": "string",
                        "enum": [
                          "single",
                          "multiple"
                        ]
                      },
                      "feedback": {
                        "type": "boolean"
                      },
                      "onCorrect": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "feedbackMessage": {
                                "type": "string"
                              },
                              "slide": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              }
                            },
                            "required": [
                              "feedbackMessage"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "onWrong": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "feedbackMessage": {
                                "type": "string"
                              },
                              "slide": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              }
                            },
                            "required": [
                              "feedbackMessage"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "questionText",
                      "answers",
                      "correctAnswers"
                    ]
                  },
                  "quizType": {
                    "type": "string",
                    "enum": [
                      "single",
                      "multiple",
                      "true-false",
                      "mixed"
                    ]
                  },
                  "answersCount": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "shouldRegenerateFeedback": {
                    "default": false,
                    "type": "boolean"
                  },
                  "instructions": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "polish_wording",
                        "improve_clarity",
                        "make_concise",
                        "more_professional",
                        "more_engaging",
                        "more_simple",
                        "more_conversational"
                      ]
                    }
                  }
                },
                "required": [
                  "mode",
                  "question"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The rewritten question.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "question": {
                      "$ref": "#/components/schemas/QuizQuestion"
                    },
                    "notice": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "enum": [
                                "insufficient_data"
                              ]
                            },
                            "message": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body shape invalid, or a field was sent that the chosen `mode` rejects.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorBody"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/LlmNotAllowed"
          },
          "500": {
            "description": "The LLM call failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "regenerate-quiz-question"
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "tags": [
    {
      "name": "Quiz",
      "description": "Generate and rewrite quiz questions with an LLM. Nothing is persisted — save the result onto a slide yourself."
    }
  ],
  "_id": {
    "buffer": {
      "0": 106,
      "1": 154,
      "2": 229,
      "3": 101,
      "4": 201,
      "5": 178,
      "6": 243,
      "7": 252,
      "8": 223,
      "9": 58,
      "10": 69,
      "11": 151
    }
  }
}
````