openapi: 3.1.0 info: title: AI+ API Contract version: 0.0.2 servers: - url: http://localhost:8000 paths: /health: get: summary: Health check responses: "200": description: API health content: application/json: schema: $ref: "#/components/schemas/HealthResponse" /api/generate: post: summary: Generate learning content requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GenerateRequest" responses: "200": description: Generated content content: application/json: schema: $ref: "#/components/schemas/GeneratedContent" "422": $ref: "#/components/responses/ApiError" "429": $ref: "#/components/responses/ApiError" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" "504": $ref: "#/components/responses/ApiError" /api/search: post: summary: Search relevant docs (stub) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SearchRequest" responses: "200": description: Search results content: application/json: schema: $ref: "#/components/schemas/SearchResponse" /api/validate: post: summary: Validate generated content requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ValidateRequest" responses: "200": description: Validation status content: application/json: schema: $ref: "#/components/schemas/ValidateResponse" /api/recommendations: post: summary: Get recommendations (stub) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RecommendationsRequest" responses: "200": description: Recommendation list content: application/json: schema: $ref: "#/components/schemas/RecommendationsResponse" /api/chat: post: summary: Chat with tutor/manager assistant requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ChatRequest" responses: "200": description: Chat assistant response content: application/json: schema: $ref: "#/components/schemas/ChatResponse" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" /api/assessment/questions: post: summary: Generate level assessment questions requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AssessmentQuestionsRequest" responses: "200": description: Assessment questions and fallback metadata content: application/json: schema: $ref: "#/components/schemas/AssessmentQuestionsResponse" /api/assessment/analyze: post: summary: Analyze assessment answers requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AssessmentAnalyzeRequest" responses: "200": description: Assessed learner level content: application/json: schema: $ref: "#/components/schemas/AssessmentAnalyzeResponse" "502": $ref: "#/components/responses/ApiError" /api/curriculum/generate: post: summary: Generate curriculum requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CurriculumGenerateRequest" responses: "200": description: Curriculum output content: application/json: schema: $ref: "#/components/schemas/CurriculumOutput" "422": $ref: "#/components/responses/ApiError" "429": $ref: "#/components/responses/ApiError" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" "504": $ref: "#/components/responses/ApiError" /api/curriculum/refine: post: summary: Refine existing curriculum via chat input requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CurriculumRefineRequest" responses: "200": description: Refined curriculum output content: application/json: schema: $ref: "#/components/schemas/CurriculumOutput" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" /api/curriculum/reasoning: post: summary: Generate pedagogical reasoning (phase 1) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReasoningRequest" responses: "200": description: Pedagogical reasoning output content: application/json: schema: $ref: "#/components/schemas/ReasoningResponse" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" /api/curriculum/sections: post: summary: Generate sectioned content (phase 2) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SectionsRequest" responses: "200": description: Sectioned content output content: application/json: schema: $ref: "#/components/schemas/SectionsResponse" "422": $ref: "#/components/responses/ApiError" "429": $ref: "#/components/responses/ApiError" "502": $ref: "#/components/responses/ApiError" "503": $ref: "#/components/responses/ApiError" "504": $ref: "#/components/responses/ApiError" /api/auth/callback: get: summary: Auth callback redirect parameters: - name: code in: query required: false schema: type: string - name: next in: query required: false schema: type: string default: /dashboard responses: "307": description: Redirect to dashboard/login components: responses: ApiError: description: Structured API error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" schemas: HealthResponse: type: object required: [status, env] properties: status: type: string env: type: string ErrorResponse: type: object required: [error_code, message, retryable, trace_id, detail] properties: error_code: type: string enum: - schema_mismatch - rate_limited - timeout - quality_failed - config_error - empty_output - provider_error - db_error - unknown message: type: string retryable: type: boolean trace_id: type: string detail: oneOf: - type: string - type: object additionalProperties: true GenerateRequest: type: object required: [language, topic] properties: language: type: string topic: type: string difficulty: type: string default: beginner targetAudience: type: string default: learner teachingMethod: type: string default: direct_instruction contentMode: type: string default: lesson enum: [lesson, quiz_only] questionCount: type: integer minimum: 3 maximum: 20 default: 8 CodeExample: type: object required: [title, code, explanation, language] properties: title: type: string code: type: string explanation: type: string language: type: string QuizQuestion: type: object required: [question, options, correct_answer, explanation] properties: question: type: string options: type: array minItems: 4 maxItems: 4 items: type: string correct_answer: type: integer minimum: 0 maximum: 3 explanation: type: string GeneratedContent: type: object required: [title, content, code_examples, quiz] properties: title: type: string content: type: string code_examples: type: array items: $ref: "#/components/schemas/CodeExample" quiz: type: array minItems: 1 maxItems: 20 items: $ref: "#/components/schemas/QuizQuestion" SearchRequest: type: object required: [query] properties: query: type: string language: type: string nullable: true topK: type: integer nullable: true default: 5 SearchChunk: type: object required: [text, source] properties: text: type: string source: type: string SearchResponse: type: object required: [chunks] properties: chunks: type: array items: $ref: "#/components/schemas/SearchChunk" ValidateRequest: type: object required: [content] properties: content: type: string type: type: string default: generated ValidateResponse: type: object required: [ok] properties: ok: type: boolean RecommendationsRequest: type: object required: [userId] properties: userId: type: string limit: type: integer nullable: true default: 5 RecommendationItem: type: object required: [contentId, reason] properties: contentId: type: string reason: type: string RecommendationsResponse: type: object required: [items] properties: items: type: array items: $ref: "#/components/schemas/RecommendationItem" ChatRequest: type: object properties: messages: type: array items: type: object additionalProperties: true chatType: type: string default: manager contextId: type: string nullable: true context: type: object additionalProperties: true ChatResponse: type: object required: [chatType, contextId, assistant, streaming] properties: chatType: type: string contextId: type: string nullable: true assistant: type: string streaming: type: boolean AssessmentQuestionsRequest: type: object required: [goal] properties: goal: type: string background: type: string nullable: true interests: type: array items: type: string AssessmentQuestion: type: object required: [id, question, options, correct_answer, difficulty, topic_area] properties: id: type: integer question: type: string options: type: array minItems: 4 maxItems: 4 items: type: string correct_answer: type: integer minimum: 0 maximum: 3 difficulty: type: string enum: [easy, medium, hard] topic_area: type: string AIFallbackMeta: type: object required: [fallback_used, failure_kind, attempt_count] properties: fallback_used: type: boolean failure_kind: type: string nullable: true attempt_count: type: integer minimum: 1 AssessmentQuestionsResponse: type: object required: [questions, meta] properties: questions: type: array minItems: 5 maxItems: 10 items: $ref: "#/components/schemas/AssessmentQuestion" meta: $ref: "#/components/schemas/AIFallbackMeta" AssessmentAnswer: type: object required: [question_id, selected] properties: question_id: type: integer selected: type: integer AssessmentAnalyzeRequest: type: object required: [goal, questions, answers] properties: goal: type: string questions: type: array items: $ref: "#/components/schemas/AssessmentQuestion" answers: type: array items: $ref: "#/components/schemas/AssessmentAnswer" AssessmentAnalyzeResponse: type: object required: [level, summary, strengths, weaknesses] properties: level: type: string enum: [beginner, intermediate, advanced] summary: type: string strengths: type: array items: type: string weaknesses: type: array items: type: string CurriculumTopic: type: object required: [title, description, estimated_minutes] properties: title: type: string description: type: string estimated_minutes: type: integer CurriculumOutput: type: object required: [title, topics, total_estimated_hours, summary] properties: title: type: string topics: type: array items: $ref: "#/components/schemas/CurriculumTopic" total_estimated_hours: type: number summary: type: string CurriculumGenerateRequest: type: object required: [goal, level] properties: goal: type: string level: type: string strengths: type: array items: type: string weaknesses: type: array items: type: string background: type: string nullable: true interests: type: array items: type: string teachingMethod: type: string default: direct_instruction goalType: type: string default: hobby weeklyStudyHours: type: integer default: 5 learningStyle: type: string default: concept_first CurriculumChatMessage: type: object required: [role, content] properties: role: type: string content: type: string CurriculumRefineRequest: type: object required: [currentCurriculum, userMessage] properties: currentCurriculum: $ref: "#/components/schemas/CurriculumOutput" chatHistory: type: array items: $ref: "#/components/schemas/CurriculumChatMessage" userMessage: type: string LearnerFeedback: type: object additionalProperties: true ConceptFocus: type: object additionalProperties: true ReasoningRequest: type: object required: [topic, curriculumGoal, learnerLevel, language] properties: topic: type: string topicDescription: type: string default: "" curriculumGoal: type: string learnerLevel: type: string language: type: string teachingMethod: type: string default: direct_instruction prevTopics: type: array items: type: string nextTopics: type: array items: type: string learnerFeedback: type: array items: $ref: "#/components/schemas/LearnerFeedback" learnerConceptFocus: type: array items: $ref: "#/components/schemas/ConceptFocus" learningStyle: type: string default: concept_first ReasoningResponse: type: object required: - learning_objectives - prerequisite_concepts - why_this_topic - teaching_strategy - difficulty_calibration - connection_to_goal properties: learning_objectives: type: array items: type: string prerequisite_concepts: type: array items: type: string why_this_topic: type: string teaching_strategy: type: string difficulty_calibration: type: string connection_to_goal: type: string ContentSection: type: object required: [type, title, body, code, explanation, question, options, correct_answer, next_preview] properties: type: type: string title: type: string body: type: string code: type: string explanation: type: string question: type: string options: type: array items: type: string correct_answer: type: integer next_preview: type: string SectionsRequest: type: object required: [input, reasoning] properties: input: $ref: "#/components/schemas/ReasoningRequest" reasoning: type: object additionalProperties: true SectionsResponse: type: object required: [title, sections, meta] properties: title: type: string sections: type: array items: $ref: "#/components/schemas/ContentSection" meta: $ref: "#/components/schemas/AIFallbackMeta"