> For the complete documentation index, see [llms.txt](https://arlinear.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arlinear.gitbook.io/documentation/api/generate-quiz.md).

# /generate-quiz

Create a new quiz with custom settings and receive a unique quiz ID + quiz data.

**Input Parameters**

<table><thead><tr><th>Parameter</th><th>Type</th><th width="139">Default</th><th>Description</th></tr></thead><tbody><tr><td>numQuizzes</td><td>Int</td><td><code>1</code></td><td>The number of quizzes you want to generate. Optional.</td></tr><tr><td>numQuestions</td><td>Int</td><td><code>10</code></td><td>Number of questions in the quiz. Optional.</td></tr><tr><td>subject</td><td>String</td><td><code>null</code></td><td>The subject of the quiz. Optional.</td></tr><tr><td>instructions</td><td>String</td><td><code>null</code></td><td>Instructions for the quiz. Optional.</td></tr><tr><td>gradeLevel</td><td>String</td><td><code>null</code></td><td>Target grade level. Optional.</td></tr><tr><td>difficulty</td><td>String</td><td><code>null</code></td><td>Difficulty level. Options: <code>""</code>, <code>Easy</code>, <code>Medium</code>, <code>Hard</code>. Optional.<br><br><strong>Note:</strong> If left blank... the difficulty of the quiz will be set at the AI's discretion.</td></tr><tr><td>pdfLinks</td><td>Array of Strings</td><td><code>null</code></td><td>Link your PDF(s) to the prompt for quiz generation via file URLs. Optional</td></tr><tr><td>videoLinks</td><td>Array of Strings</td><td><code>null</code></td><td>Link your videos (.mp4 or youtube) to the prompt for quiz generation. <strong>Currently in closed beta</strong>, <a href="https://arlinear.com/contact-us/">inquire with sales to access.</a></td></tr><tr><td>files</td><td>Array of FIles</td><td><code>null</code></td><td>Upload a file directly using form data, it works the same as "pdfLinks".</td></tr></tbody></table>

**Note:** For **`subject`**, **`instructions`**, and **`gradeLevel`**... if either one is left blank, the AI will use any of the values as context in order to create the quiz. If nothing is passed, you will generate a random quiz.

**Example Request**

```javascript
// Example to generate a quiz
fetch('https://api.arlinear.com/functions/v1/generate-quiz', {
    method: 'POST',
    headers: {
        'Authorization': '<Your API Key>',
    },
    body: JSON.stringify({
	'numQuizzes': 2,
        'subject': 'Math',
        'instructions': 'A quiz on basic algebra',
        'gradeLevel': 'grade 6',
        'difficulty': 'Medium',
        'numQuestions': 20
    })
})
```

**Return Value**

* `quizzes`
  * An array of quizzes.
  * `quizId`: A unique identifier for the generated quiz.
  * `title`: The title of the quiz.
  * `questions`: The questions in the quiz.

```json
{
    "quizzes": [ // list of quizzes
	{
	  "quizId": "ba777045-7033-4701-b17b-da9e90dcd41e",
	  "title": "Basic Algebra Quiz 1",
	  "questions": [
            {
                "id": "d93bdcaf-0490-4cb7-af55-bfcb07c33332",
                "type": "mc",
                "value": "What is the result of 5 + 2 * 3?",
                "choices": [
                    {
                        "value": " 11",
                        "isCorrect": true,
                        "type": "choice"
                    },
                    {
                        "value": " 14",
                        "isCorrect": false,
                        "type": "choice"
                    },
                    {
                        "value": " 9",
                        "isCorrect": false,
                        "type": "choice"
                    }
                ]
            },
            {
                "id": "d93bdcaf-0490-4cb7-af55-bfcb07c33332",
                "type": "short",
                "value": "Solve for x: 3x + 2 = 8",
                "gradingCriteria": "Grading Criteria: \"This quiz is for 1st graders. They should be able to perform simple order of operations.\""
            }
	  ]
	},
	{
	  "quizId": "ba777045-7033-4701-b17b-da9e90dcd41e",
	  "title": "Basic Algebra Quiz 2",
	  "questions": [...]
	},
    ]
}
```
