Detective AI
AI Murder Mystery on iOS
Detective AI is a native iOS game where you interrogate live AI avatars to solve a murder case. You pick a suspect from the board, tap to call, and a real video session opens — the avatar sees and hears you, answers your questions in character, and reveals evidence as you press them. The entire game runs on voice and conversation. No multiple-choice prompts, no scripted branches.
The app is built in Swift/SwiftUI on top of
Runway's Characters API. Runway only ships a
React web SDK, so I reverse-engineered the API by reading their SDK source to map out the REST endpoints (create session, poll until ready, consume credentials), the two-tier auth model, and the WebRTC signaling flow. The key discovery: the entire real-time layer runs on
LiveKit under the hood, not raw WebRTC — which meant I could use the
LiveKit Swift SDK directly instead of building a React Native bridge.
The most interesting design problem: the avatar isn't reliable as a game engine. It's focused on being a convincing character, not remembering to fire tool calls at the right moments. My first version relied on the avatar's built-in tool system and clues dropped erratically — sometimes in bursts, sometimes not at all. The fix was to add a **separate AI 'Game Master'** layer. Every time the suspect speaks, the LiveKit transcription is sent to GPT-4o-mini along with the full scenario context. GPT-4o-mini analyzes what was just said against the known truth and returns structured JSON: clues detected, contradictions caught, a contextual next question, suspicion level, and a 'detective instinct' hint. The avatar acts; the Game Master scores. This is the difference between 'hoping the AI remembers to press a button' and 'having a dedicated AI analyzing every word.'
The game is also a playground for fast experimentation with generative media. Case briefings are narrated via
ElevenLabs TTS with word-level timing for karaoke-style highlighting. Pre-generated audio is cached as static files on the backend so every player gets instant playback. The UI is built with a noir detective theme I designed myself — warm amber glow, deep blue-black backgrounds, serif typography, and floating FaceTime-style call controls.
All API keys live on a Vercel serverless backend proxy. The iOS app has zero secrets in the binary — just a revocable app token. Anyone can clone the repo, but they can't see the keys.
The first playable scenario is 'The Vanishing Act at Villa Morada.' Three suspects — a business partner, a rival collector, and the private chef — each with 1,500-character personality prompts encoding their backstory, secrets, and behavioral triggers. The chef did it. Good luck proving it in five minutes.