npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-quiz

v2.0.0

Published

AI Quiz App

Downloads

185

Readme

AI Quiz

The AI Quiz SDK is a React component library that drops an AI-generated quiz UI into any app. The SDK never touches your OpenAI key — you host a tiny server proxy and point the component at it, so secrets stay on the server.

Installation

npm install ai-quiz

Usage

import { QuizComponent } from 'ai-quiz';

export default function Page() {
  return <QuizComponent topic="AWS Lambda" endpoint="/api/quiz" />;
}

Props

| Prop | Type | Required | Description | | ---------- | ----------------------------- | -------- | --------------------------------------------------------------------------- | | topic | string | yes | Default topic seeded into the quiz form. | | endpoint | string | one of | URL of your server proxy. The SDK POSTs to it. Easiest option. | | fetcher | QuizFetcher | one of | Custom async function — use this for non-HTTP transports or extra headers. |

You must supply either endpoint or fetcher. Never pass an API key to a browser component — anyone viewing your site can read it.

Server contract

The SDK POSTs JSON to your endpoint:

{
  "system": "string",
  "user": "string",
  "model": "gpt-3.5-turbo",
  "temperature": 1
}

Your endpoint must respond with:

{ "content": "<raw model output as a string>" }

That's it — the shape is provider-agnostic, so you can back it with OpenAI, Anthropic, a local model, or a cache.

Example proxy (Next.js App Router)

// app/api/quiz/route.ts
import OpenAI from 'openai';

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

export async function POST(req: Request) {
  const { system, user, model, temperature } = await req.json();

  const completion = await openai.chat.completions.create({
    model,
    temperature,
    messages: [
      { role: 'system', content: system },
      { role: 'user', content: user },
    ],
  });

  return Response.json({ content: completion.choices[0].message.content ?? '' });
}

Example proxy (Express)

import express from 'express';
import OpenAI from 'openai';

const app = express();
app.use(express.json());
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

app.post('/api/quiz', async (req, res) => {
  const { system, user, model, temperature } = req.body;
  const completion = await openai.chat.completions.create({
    model,
    temperature,
    messages: [
      { role: 'system', content: system },
      { role: 'user', content: user },
    ],
  });
  res.json({ content: completion.choices[0].message.content ?? '' });
});

Custom fetcher

Use a fetcher when you need auth headers, a non-OpenAI backend, request signing, or anything beyond a plain POST:

import { QuizComponent, QuizFetcher } from 'ai-quiz';

const fetcher: QuizFetcher = async ({ system, user, model, temperature }) => {
  const res = await fetch('/api/quiz', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${await getSessionToken()}`,
    },
    body: JSON.stringify({ system, user, model, temperature }),
  });
  const { content } = await res.json();
  return content;
};

<QuizComponent topic="AWS Lambda" fetcher={fetcher} />;

Migrating from v1

v1 accepted an apiKey argument and called OpenAI directly from the browser. That key was visible to every visitor. v2 removes the key argument entirely:

- {QuizComponent("AWS Lambda", process.env.REACT_APP_OPENAI_KEY)}
+ <QuizComponent topic="AWS Lambda" endpoint="/api/quiz" />

If you have a v1 key shipped in production, rotate it immediately.

License

No license selected yet.

Contact

[email protected]