TrivAI: My First Deep Dive into AI API Integration

I'd been wanting to try building something that used an AI API directly, and I figured a trivia game would be a good place to start. I wanted to make something more involved than a basic chatbot—something where the AI was actually generating the core content of the app. TrivAI is a Jeopardy-style trivia game where Claude generates questions in real-time based on whatever categories players come up with.

Prototype

The game is designed for people playing together in the same room—game night style, not a solo mobile app. Two to eight players take turns picking questions from a board with six categories, each worth $200 to $1000 based on difficulty. The interesting part is that the categories can be literally anything. Players type in whatever they want—"90s Boy Bands" or "Obscure Pokemon Types"—and the AI validates it to make sure it works for trivia. If you can't think of categories, you can generate six random ones. There's also a feature where the AI suggests categories based on what you've already added, so if you put in "Computers" it might suggest "Programming Languages" or "Video Game Consoles" to go with it.

Working with AI-generated content means dealing with unpredictability. Sometimes you get a great question, sometimes you get something that doesn't quite make sense. To handle this, I added a "regenerate question" button so players can request a new one if something feels off, and a moderator override where a human can step in and approve or reject the AI's judgment on an answer. The answer evaluation itself uses fuzzy text matching first (fast, no API call), and only asks Claude to judge if there's ambiguity—like whether "George Washington" and "Washington" should both count as correct.

Prompt Engineering

The tricky part was getting interesting questions consistently. Early on, if you asked for "Movie Trivia" you'd just get questions about the same popular blockbusters over and over. The fix was adding randomness to the prompts. For movies, the system picks random starting letters (like M, T, and R) and tells the AI to generate questions about movies beginning with those letters. This forces variety without sacrificing quality. I use similar strategies across other categories—by constraining the AI in specific ways, the questions end up feeling less predictable.

The project taught me that working with AI APIs is less about just making requests and more about building systems around the AI's quirks. The combination of fuzzy matching for speed, AI evaluation for nuance, human moderation for weird cases, and prompt constraints for variety makes the game work. Every playthrough is different because the questions are actually different each time, and players can pick whatever categories they want, however serious or ridiculous. It's the kind of thing that wouldn't really work without AI generating content on the fly, which is what I was hoping to explore when I started.