FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
msd
msdaa
Public
Like
aa
Home
Code
5
frontend
1
README.md
H
course-generator.ts
H
frontend-handler.ts
H
test-openai.ts
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
https://msd--3237eb32329a11f0b1c3569c3dd06744.web.val.run
README.md

AI Course Generator

This Val Town project generates comprehensive course structures from user prompts using OpenAI.

Features

  • Takes a course topic as input and generates a complete course structure
  • Uses OpenAI's GPT-4o model for high-quality content generation
  • Provides a structured output with course title, description, target audience, prerequisites, learning outcomes, modules, and lessons
  • Includes a user-friendly web interface

Project Structure

  • /course-generator.ts - Core logic for generating course structures using OpenAI
  • /frontend-handler.ts - HTTP handler that serves the frontend and processes API requests
  • /frontend/index.html - Web interface for the course generator

How to Use

Web Interface

  1. Visit the frontend URL
  2. Enter a course topic in the text area (e.g., "Introduction to Machine Learning", "Web Development with React")
  3. Click "Generate Course"
  4. View the generated course structure with modules and lessons

API Usage

You can also use the course generator as an API:

// Example API call const response = await fetch('YOUR_VAL_TOWN_URL', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ prompt: 'Introduction to Machine Learning' }), }); const courseStructure = await response.json();

Response Format

The API returns a JSON object with the following structure:

{ "courseTitle": "Title of the course", "courseDescription": "A paragraph describing the course", "targetAudience": "Description of who this course is for", "prerequisites": ["Prerequisite 1", "Prerequisite 2", ...], "learningOutcomes": ["Outcome 1", "Outcome 2", ...], "modules": [ { "title": "Module title", "description": "Module description", "lessons": [ { "title": "Lesson title", "description": "Brief description of the lesson", "keyPoints": ["Key point 1", "Key point 2", ...] }, ...more lessons ] }, ...more modules ] }

Requirements

  • OpenAI API key set as an environment variable in Val Town

Setup Instructions

  1. In Val Town, go to your account settings
  2. Add an environment variable named OPENAI_API_KEY with your OpenAI API key
  3. Deploy both the course-generator.ts and frontend-handler.ts files with HTTP triggers

Troubleshooting

If the application isn't generating any responses, check the following:

  1. OpenAI API Key: Make sure you've set the OPENAI_API_KEY environment variable in Val Town
  2. Console Logs: Check the Val Town logs for any error messages
  3. Browser Console: Open your browser's developer tools to check for any JavaScript errors
  4. API Limits: If you're using a free OpenAI API key, you might have hit your usage limits
HTTP
  • course-generator.ts
    msd--32…44.web.val.run
  • frontend-handler.ts
    msd--4b…44.web.val.run
  • test-openai.ts
    msd--9d…44.web.val.run
Code
frontendREADME.md
H
course-generator.ts
H
frontend-handler.ts
H
test-openai.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.