openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: MathQuest Live API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: game description: MathQuest Live game operations - name: images description: Temporary generated image operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /game/start: post: operationId: startGame tags: [game] summary: Start a new game adventure description: Generates the first scene of the adventure requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StartGameBody" responses: "200": description: First story scene content: application/json: schema: $ref: "#/components/schemas/StoryTurnResponse" /game/turn: post: operationId: takeTurn tags: [game] summary: Advance the adventure by one turn description: Generates the next scene based on the chosen action requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TakeTurnBody" responses: "200": description: Next story scene content: application/json: schema: $ref: "#/components/schemas/StoryTurnResponse" /game/prepare: post: operationId: prepareGameStep tags: [game] summary: Prepare the next story step while math is being solved description: Starts background generation for the next scene or ending after a student chooses an action requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PrepareGameStepBody" responses: "200": description: Prepared step handle content: application/json: schema: $ref: "#/components/schemas/PrepareGameStepResponse" /game/resolve: post: operationId: resolvePreparedGameStep tags: [game] summary: Resolve a prepared story step after math is solved description: Returns the prepared scene or ending once the student has solved the math challenge requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ResolvePreparedGameStepBody" responses: "200": description: Prepared story step content: application/json: schema: $ref: "#/components/schemas/ResolvePreparedGameStepResponse" /game/ending: post: operationId: getEnding tags: [game] summary: Generate the adventure ending description: Generates the final ending scene after the configured number of math-gated chapters requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GetEndingBody" responses: "200": description: Adventure ending content: application/json: schema: $ref: "#/components/schemas/EndingResponse" /images/status/{imageJobId}: get: operationId: getImageJobStatus tags: [images] summary: Get generated scene image job status description: Returns the current metadata for a temporary generated image job parameters: - name: imageJobId in: path required: true schema: type: string responses: "200": description: Temporary generated image job status content: application/json: schema: $ref: "#/components/schemas/StoryImage" "404": description: Image job not found or expired /images/{imageId}: get: operationId: getImage tags: [images] summary: Get a temporary generated scene image description: Returns an in-memory generated image if it has not expired parameters: - name: imageId in: path required: true schema: type: string responses: "200": description: Temporary generated image content: image/png: schema: type: string format: binary "404": description: Image not found or expired components: schemas: HealthStatus: type: object properties: status: type: string required: - status HeroInfo: type: object properties: name: type: string pronouns: type: string ancestry: type: string className: type: string required: - name - pronouns - ancestry - className StoryChoice: type: object properties: id: type: string label: type: string required: - id - label ReadyStoryImage: type: object properties: enabled: type: boolean const: true status: type: string enum: - ready imageId: type: string url: type: string alt: type: string provider: type: string model: type: string required: - enabled - status - imageId - url - alt - provider - model PendingStoryImage: type: object properties: enabled: type: boolean const: true status: type: string enum: - pending imageId: type: string statusUrl: type: string alt: type: string provider: type: string model: type: string required: - enabled - status - imageId - statusUrl - alt - provider - model FailedStoryImage: type: object properties: enabled: type: boolean const: true status: type: string enum: - failed error: type: string enum: - image_generation_failed required: - enabled - status - error StoryImage: oneOf: - $ref: "#/components/schemas/ReadyStoryImage" - $ref: "#/components/schemas/PendingStoryImage" - $ref: "#/components/schemas/FailedStoryImage" StoryTurnResponse: type: object properties: episodeId: type: string sceneTitle: type: string storyText: type: string choices: type: array items: $ref: "#/components/schemas/StoryChoice" storySummary: type: string storyHistory: type: string safetyRating: type: string image: $ref: "#/components/schemas/StoryImage" required: - sceneTitle - storyText - choices - storySummary - safetyRating EndingResponse: type: object properties: endingTitle: type: string endingText: type: string badge: type: string safetyRating: type: string image: $ref: "#/components/schemas/StoryImage" required: - endingTitle - endingText - badge - safetyRating StartGameBody: type: object properties: hero: $ref: "#/components/schemas/HeroInfo" difficulty: type: string adventureSeed: type: string maxTurns: type: integer required: - hero - difficulty - adventureSeed - maxTurns TakeTurnBody: type: object properties: hero: $ref: "#/components/schemas/HeroInfo" difficulty: type: string adventureSeed: type: string turn: type: integer maxTurns: type: integer storySummary: type: string storyHistory: type: string episodeId: type: string chosenAction: type: string mathResult: type: string required: - hero - difficulty - adventureSeed - turn - maxTurns - storySummary - chosenAction - mathResult PrepareGameStepBody: type: object properties: kind: type: string enum: - turn - ending hero: $ref: "#/components/schemas/HeroInfo" difficulty: type: string adventureSeed: type: string turn: type: integer maxTurns: type: integer storySummary: type: string storyHistory: type: string episodeId: type: string chosenAction: type: string mathSolved: type: integer lastMathSkill: $ref: "#/components/schemas/LastMathSkill" required: - kind - hero - difficulty - adventureSeed - turn - maxTurns - storySummary - chosenAction LastMathSkill: type: object properties: skillLabel: type: string problemType: type: string difficulty: type: string gradeBand: type: integer storyFlavor: type: string required: - skillLabel - problemType - difficulty - gradeBand - storyFlavor PrepareGameStepResponse: type: object properties: pendingId: type: string kind: type: string enum: - turn - ending turn: type: integer required: - pendingId - kind - turn ResolvePreparedGameStepBody: type: object properties: pendingId: type: string required: - pendingId ResolvePreparedGameStepResponse: oneOf: - type: object properties: kind: type: string const: turn turn: type: integer data: $ref: "#/components/schemas/StoryTurnResponse" required: - kind - turn - data - type: object properties: kind: type: string const: ending turn: type: integer data: $ref: "#/components/schemas/EndingResponse" required: - kind - turn - data GetEndingBody: type: object properties: hero: $ref: "#/components/schemas/HeroInfo" difficulty: type: string adventureSeed: type: string turn: type: integer maxTurns: type: integer storySummary: type: string storyHistory: type: string episodeId: type: string mathSolved: type: integer required: - hero - difficulty - adventureSeed - turn - maxTurns - storySummary - mathSolved