Question generation
POST /v1/questions/generatePOST /v1/questions/generate/batchfrom $0.10 / 1M tokensTurns a passage into the questions it answers, in your own words rather than copied from the text. Built for training and testing search and RAG systems in bulk: run your corpus through it to get (question, passage) pairs for fine-tuning embedders and rerankers, or a test set that checks your search finds the right passage. It also works for FAQs and study cards. Powered by MIST-QG-1.1, trained on passages in 324 languages.
r = call("/v1/questions/generate", { "passage": "Ocean tides are caused mainly by the gravitational pull of the Moon on the Earth...", "n": 3})print(r["questions"])Request
Section titled “Request”| Field | Default | Notes |
|---|---|---|
passage |
required | 1 to 100,000 characters. A passage over about 2,000 characters is split into chunks of that size, and the questions are spread over them: see Long passages. |
n |
3 |
How many questions: 1 to 100 (at most 5 per 2,000 characters of passage), or "auto" to let the model write as many as the passage supports (usually about two per 2,000 characters). |
language |
detected | Optional. The passage’s language, as a name or code: yor, yo or Yoruba. Detected for you when left out. |
question_language |
the passage’s | Optional. Write the questions in another language: see Cross-lingual questions. |
Response
Section titled “Response”{"questions": ["What causes ocean tides?", "...", "..."], "language": "eng", "question_language": "eng", "model": "mist-qg-1.1", "warnings": [], "usage": {"input_tokens": 96, "output_tokens": 27, "generations": 1}}language is the passage’s language and question_language the questions’. warnings flags a very short passage, a passage whose language couldn’t be told, a count above what the passage’s length allows, or a passage that supports fewer distinct questions than you asked for.
How many questions
Section titled “How many questions”- A number is a maximum, in the passage’s own language or across languages. A short passage that only supports two good questions gives two, not five padded ones, and
warningssays so. "auto": the model decides from the passage. Use it when every question must be one the text really answers, such as training pairs.- Repeats are removed. If the model writes the same question twice, or two near-identical versions of it, you get it once,
warningssays so, and you aren’t charged for the removed ones.
Long passages
Section titled “Long passages”Send a whole article, chapter or report section, up to 100,000 characters. The model writes its best questions on about 2,000 characters at a time, so a longer passage is split into chunks of about that size at paragraph or sentence breaks, all generated together in one call:
- A number is spread over the chunks in proportion to their length, at most 5 per chunk, so the questions cover the whole passage. With fewer questions than chunks, they come from chunks spread evenly through it.
"auto"lets each chunk give as many as it supports.- Repeats across chunks are removed once, and you aren’t charged for them.
The questions come back in passage order. A batch takes up to 200,000 characters in all.
Cross-lingual questions
Section titled “Cross-lingual questions”Set question_language to get questions in a different language from the passage:
- Any passage → English or French. A Yorùbá, Quechua or Hausa passage can give English or French questions.
- English or French passage → 30 widely spoken languages: Afrikaans, Amharic, Arabic, Bengali, Chinese, Dutch, German, Hausa, Hindi, Igbo, Indonesian, Italian, Japanese, Korean, Persian, Polish, Portuguese, Russian, Somali, Spanish, Swahili, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Yoruba and Zulu.
- Between any two of those 30, such as Swahili → Hindi.
Other directions return 400 with the reason. Each cross-lingual question is checked with language ID: one the model wrote in the passage’s language or in English instead is removed, warnings says so, and you aren’t charged for it.
r = call("/v1/questions/generate", { "passage": "Ọjà Ọ̀jọ̀ jẹ́ ọjà ìbílẹ̀ tó gbajúmọ̀ ní ìlú Ìbàdàn...", "question_language": "English", "n": 2})POST /v1/questions/generate/batch with "passages": [...] (up to 64, in any mix of languages, with the same n, language and question_language fields) returns {"results": [[...], [...]], "languages": [...], "question_languages": [...]}.