Skip to main content
A TypeScript-based agent that generates educational quizzes using LangChain and OpenRouter.

Code

Create quiz-generator-agent.ts with the code below, or save it directly from your editor.

Skill Configuration

Create skills/quiz-generation/skill.yaml:

How It Works

TypeScript Integration
  • Uses @bindu/sdk for Bindu protocol compliance
  • LangChain integration with @langchain/openai
  • Type-safe development with TypeScript
LLM Configuration
  • OpenRouter API via baseURL override
  • GPT-OSS-120b model for high-quality output
  • Low temperature (0.3) for consistent quiz generation
Quiz Generation
  • System prompt with detailed formatting instructions
  • Exactly 10 MCQs per request
  • 4 options per question (A, B, C, D)
  • One correct answer with explanation
  • Academic language and structured markdown output
Error Handling
  • Graceful error handling with descriptive messages
  • Input validation for message arrays
  • Response type checking and formatting

Dependencies

Environment Setup

Create .env file:

Run

Examples:
  • “Generate a quiz about World War II”
  • “Create a quiz based on this chapter about photosynthesis”
  • “Make a quiz about basic mathematics concepts”
  • “Generate assessment questions for this programming tutorial”

Example API Calls

Frontend Setup

Open http://localhost:5173 and try to chat with the quiz generator agent