Skip to content

feat: extend /api/generate-classroom to support full generation features (web search, image, video, TTS) #49

@cosarah

Description

@cosarah

Background

The current /api/generate-classroom API only accepts 3 parameters:

interface GenerateClassroomInput {
  requirement: string;
  pdfContent?: { text: string; images: string[] };
  language?: string;
}

However, the web UI's client-side generation pipeline already supports additional features:

  • Web search — enriches outline generation with real-time web context (UserRequirements.webSearch)
  • Image generation — generates images for slides via imageGenerationEnabled + image providers
  • Video generation — generates video assets via videoGenerationEnabled + video providers
  • TTS generation — generates narration audio via TTS providers

These features are passed via custom headers (x-image-generation-enabled, x-video-generation-enabled, etc.) in the client-side flow but are completely missing from the server-side generateClassroom() pipeline used by the API.

Goal

Extend GenerateClassroomInput to support these feature toggles so that API callers (e.g., OpenClaw) can control them:

interface GenerateClassroomInput {
  requirement: string;
  pdfContent?: { text: string; images: string[] };
  language?: string;
  // New fields
  enableWebSearch?: boolean;    // Enable web search for richer context
  enableImageGeneration?: boolean; // Generate images for slides
  enableVideoGeneration?: boolean; // Generate video assets
  enableTTS?: boolean;           // Generate narration audio (TTS)
}

Implementation Tasks

1. Extend GenerateClassroomInput interface

  • Add the 4 optional boolean fields to lib/server/classroom-generation.ts

2. Wire up features in generateClassroom()

  • Web search: Pass webSearch flag to UserRequirements → used by generateSceneOutlinesFromRequirements()
  • Image generation: Pass imageGenerationEnabled to outline generator options, integrate media orchestrator for image generation after scenes are built
  • Video generation: Pass videoGenerationEnabled to outline generator options, integrate media orchestrator for video generation
  • TTS: Add TTS generation step after scene content is finalized (similar to client-side generateTTSForScene())

3. Update API route

  • Accept new fields in app/api/generate-classroom/route.ts
  • Pass them through to generateClassroom()

4. Feature availability detection

  • Server already auto-detects available providers via getServerImageProviders(), getServerVideoProviders(), getServerTTSProviders(), getServerWebSearchProviders() in lib/server/provider-config.ts
  • If a feature is requested but no provider is configured, either gracefully skip or return an error

5. Update OpenClaw skill documentation

skills/openmaic/references/generate-flow.md

  • Document new optional fields in the request body
  • Add examples showing how to enable each feature

skills/openmaic/references/provider-keys.md

  • Add guidance for configuring image, video, TTS, and web search providers
  • Explain which env vars to set for each capability

skills/openmaic/SKILL.md

  • Local mode: During setup (Phase 3), ask the user which optional features they want to enable (web search, image gen, video gen, TTS), then guide them to configure the corresponding provider keys
  • Hosted mode: Use the live demo's default configuration (no need to ask — features are pre-configured server-side)

6. Add capabilities endpoint (optional)

Consider adding a GET /api/capabilities or extending /api/health to return which features are available based on current server config:

{
  "status": "ok",
  "capabilities": {
    "webSearch": true,
    "imageGeneration": false,
    "videoGeneration": false,
    "tts": true
  }
}

This would help OpenClaw auto-detect what's available without trial and error.

Key Files

File Role
lib/server/classroom-generation.ts GenerateClassroomInput interface + generateClassroom() pipeline
app/api/generate-classroom/route.ts API route handler
lib/types/generation.ts UserRequirements type (already has webSearch field)
lib/generation/outline-generator.ts Accepts imageGenerationEnabled / videoGenerationEnabled options
lib/server/provider-config.ts Server-side feature availability detection
lib/hooks/use-scene-generator.ts Client-side reference impl for all features
skills/openmaic/SKILL.md OpenClaw skill SOP
skills/openmaic/references/generate-flow.md Generation API documentation
skills/openmaic/references/provider-keys.md Provider configuration guide

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions