---
title: "Generate and persist a quiz with AI"
method: POST
path: "/api/v1/quizzes/generate"
tags: ["Quizzes"]
---

# Generate and persist a quiz with AI

`POST /api/v1/quizzes/generate`

## Request

- Base URL: `https://www.quiz.video`
- URL: `https://www.quiz.video/api/v1/quizzes/generate`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://www.quiz.video/api/auth/oauth2/authorize`, token URL `https://www.quiz.video/api/auth/oauth2/token`, scopes: `api:read`)
  - OpenID Connect (`https://www.quiz.video/.well-known/openid-configuration`, scopes: `api:read`)

## Request body

- GenerateQuizRequest
  - `topic` string, required: Short topic or detailed brief (up to 20,000 characters).
  - `extraDirection` string
  - `numberOfQuestions` integer
  - `answerOptionCount` 3 | 4
  - `difficulty` 'easy' | 'medium' | 'hard' | 'rising'
  - `quizType` 'multiple_choice' | 'reveal_answer' | 'picture_guess'
  - `format` 'tiktok' | 'youtube'
  - `countdownSeconds` integer
  - `template` string
  - `progressBarStyle` 'circle' | 'line'
  - `backgroundMusicId` integer, nullable: Omit to use the default YouTube-safe shared track; set null for silent.
  - `musicVolume` number
  - `themeDescription` string: Natural-language prompt used to generate and save a custom visual theme.
  - `themeCustomization` ThemeCustomization
    - `name` string
    - `description` string
    - `accentColorOverride` string
    - `backgroundColorOverride` string
    - `secondaryColorOverride` string
    - `fontFamilyOverride` 'Inter' | 'Poppins' | 'Roboto' | 'Montserrat' | 'Open Sans' | 'Lato' | 'Oswald' | 'Raleway' | 'Playfair Display' | 'Source Sans Pro'

## Response `200`

Successful response

- object
  - `data` QuizWithQuestions, required
    - `id` string
    - `title` string
    - `description` string, nullable
    - `slug` string
    - `format` string
    - `quizType` string
    - `template` string, nullable
    - `themeCustomization` ThemeCustomization
      - `name` string
      - `description` string
      - `accentColorOverride` string
      - `backgroundColorOverride` string
      - `secondaryColorOverride` string
      - `fontFamilyOverride` 'Inter' | 'Poppins' | 'Roboto' | 'Montserrat' | 'Open Sans' | 'Lato' | 'Oswald' | 'Raleway' | 'Playfair Display' | 'Source Sans Pro'
    - `difficulty` string, nullable
    - `backgroundMusicId` integer, nullable
    - `musicVolume` number
    - `isPublished` boolean
    - `publishedAt` string, date-time, nullable
    - `views` integer
    - `plays` integer
    - `thumbnailUrl` string, uri, nullable
    - `createdAt` string, date-time
    - `updatedAt` string, date-time
    - `questions` Question[]
      - `id` integer
      - `quizId` string
      - `questionText` string
      - `ttsText` string, nullable
      - `imagePath` string, nullable
      - `order` integer
      - `duration` number
      - `answers` Answer[]
        - `answerText` string, required
        - `isCorrect` boolean
        - `additionalInfo` string
        - `ttsText` string
        - `order` integer
        - `id` integer
        - `questionId` integer
      - `images` QuestionImage[]
        - `url` string, uri, required
        - `alt` string
        - `source` string
        - `sourceUrl` string, uri
        - `width` integer
        - `height` integer
        - `id` integer
        - `questionId` integer
    - `hooks` Hook[]
      - `hookType` 'engagement' | 'reminder' | 'conclusion' | 'custom'
      - `positionType` 'after_question' | 'time_based' | 'start' | 'end'
      - `positionValue` integer
      - `title` string
      - `content` string
      - `emoji` string
      - `animationStyle` 'fade' | 'bounce' | 'slide' | 'zoom'
      - `displayDuration` integer
      - `ttsEnabled` boolean
      - `ttsText` string
      - `themeColor` string
      - `backgroundColor` string
      - `fontSize` integer
      - `enabled` boolean
      - `introTemplate` string
      - `id` integer
      - `quizId` string
      - `createdAt` string, date-time
      - `updatedAt` string, date-time

## Other responses

- `201`: Successful response
- `400`: Request validation failed (code VALIDATION_ERROR or a field-specific code)
- `401`: Missing or invalid credentials (code UNAUTHORIZED)
- `403`: Credentials are valid but lack access or scope (code FORBIDDEN or INSUFFICIENT_SCOPE)
- `404`: Resource not found (code NOT_FOUND)
- `429`: API key rate limit exceeded (code RATE_LIMITED)
- `500`: Unexpected server error (code INTERNAL_ERROR)
- `503`: A required upstream service (AI provider or render queue) is temporarily unavailable; retry with backoff

---

[API](https://skmtc.dev/quiz/apis/quiz-video-api.md) · [All operations](https://skmtc.dev/quiz/apis/quiz-video-api/llms.txt) · [OpenAPI document](https://skmtc.dev/quiz/apis/quiz-video-api/revisions/f615216b844d?raw)
