POST /v2/courses/{course_id}/generate-flashcards
Generate flashcards
Builds (or returns) a deck of flashcards covering the course material. The first call for a given (course_id, model) pair runs the full generation; later calls return the cached result instantly via from_cache: true.
Request
Headers
| Header | Required | Notes |
|---|---|---|
X-API-Key | yes | |
X-External-User-Id | yes (or X-User-Id) | Must own the course |
Content-Type | yes | application/json |
Path parameters
course_id string (UUID) required The course to generate flashcards from. |
Body
The request body is empty ({}). All generation defaults are set on the course.
Returns
{
"flashcards": {
"deck_title": "Photosynthesis: From Light to Life",
"cards": [
{ "front": "Define chlorophyll-a.",
"back": "The primary pigment in green plants; absorbs blue (430 nm) and red (662 nm) light." },
{ "front": "Which cycle fixes CO₂ to G3P?",
"back": "The Calvin cycle." }
],
"total": 24
},
"from_cache": false
}
Switching models invalidates the cache for that course (the new model produces a fresh deck on first call). To force regeneration with the same model, this endpoint doesn’t currently expose a flag — contact support if you need it.
Errors
- 404 — Course not found.
- 422 — Unknown
model. - 503 — Upstream LLM unavailable. Retry with backoff.