smartnpcs.com • Production v0.1

Give Your Browser Games
A Brain in 5 Lines of Code

The hosted NPC engine built for browser games and AI game builders. Reactivity is the primitive: your game reports an event, your NPC picks a behaviour token, and conversation happens only when needed — with persistent memory and hard spend caps.

Grom the Blacksmith
ID: smith • Model: @smartnpcs/dual-adapter
⚡ 14ms Edge Cache
Trigger Game Event
Client Received Reaction[TRADE]
Grom:

"Now that's what I call honest coin. Take a look at these tempered steel blades, traveler."

Mood:Friendly
Action Enum:open_trade_menu
Authority:✓ Verified Untampered
{
  "behaviour": "trade",
  "say": "Now that's what I call honest coin. Take a look at these tempered steel blades, traveler.",
  "action": "open_trade_menu",
  "degraded": 0
}
Client SDK

One Import. Five Lines. Zero Server.

No API secrets in the browser. No prompt templating. No fragile wrappers. The NPC logic, memory, and allowed behaviour vocabulary live securely in the cloud.

main.js
import { npc } from '@npc/client';

// 1. Initialize NPC brain with public key & character ID
const smith = npc({
  key: 'pk_live_your_game_key',
  id: 'smith',
});

// 2. React to game events from your physics or input loop
async function onPlayerInteract(event, worldState) {
  // react() NEVER throws. Always returns guaranteed behaviour.
  const reaction = await smith.react(event, worldState);

  switch (reaction.behaviour) {
    case 'greet':     playAnimation('wave'); break;
    case 'warn':      playAnimation('angry'); break;
    case 'offer_deal': openShopUI(); break;
    case 'throw_out': ejectPlayer(); break;
  }

  if (reaction.say) {
    showSpeechBubble(reaction.say);
  }
}

// 3. Fire-and-forget background observations (memory only)
smith.observe('player completed the dragon cavern quest');
The Missing Backend

Everything a Vibe-Coded Game Can't Build

Vibe-coding platforms generate client-side code in seconds. But client-side apps have no database, no anti-cheat, no secret storage, and no spend controls. Smart NPCs is the plug-and-play backend.

🧠

Persistent Player Memory

Remembers player actions, reputations, and decisions across browser tabs and game sessions without running a database.

🛡️

Anti-Cheat Authority Boundary

Game rules and player state are verified on the edge. Players cannot open DevTools to inject 9999 gold into the NPC dialogue prompt.

🔑

Zero-Secret Public Key

Use pk_live_... keys right inside your client-side JavaScript. Never risk exposing master OpenAI or Fireworks API secrets.

🛑

Hard Spend Caps & Predictability

Set strict monthly or daily spend limits per game. If your game goes viral, your costs will never blow past your budget.

⚡

Sub-800ms Edge Latency

Cloudflare Workers edge delivery across 330+ cities worldwide. Cached common interactions return in under 15ms.

🎯

Measurable Invariant Evals

Tested against R1–R5 benchmarks (Refusal, Diversity, State Consistency, Latency, and Moderation) on every deployment.

Direct Architecture Comparison

Why inline raw LLM calls break down in production games

CapabilityRaw Client-Side LLM CallSmart NPCs (smartnpcs.com)
State & Memory❌ Wiped on browser refresh✅ Permanent cross-session player working memory
Security❌ API key exposed in DevTools✅ Scoped public key (pk_live_...) with zero secret risk
Cost Control❌ Infinite liability on viral spikes✅ Hard dollar spend caps with automatic fallback
Response Type❌ Unpredictable raw prose text✅ Strict game-ready behaviour token enum
Latency (P95)❌ 1,500ms – 4,000ms✅ < 800ms (14ms on semantic cache hit)
Playable Examples

See It Live in Real Game Loops

Explore fully functioning browser games powered by the Smart NPCs client SDK. Both examples are available directly in the monorepo.

Live Browser Game

Shopkeeper Barter & Theft Demo

Interact with a gruff medieval blacksmith. Test bargaining, item trade, and what happens when a player draws a weapon or tries to steal an enchanted potion.

• Event-in, behaviour-enum-out• Anti-cheat inventory check• Sub-20ms cached barters
Phaser & WebGL Style

Dungeon Guardian RPG Demo

A dark fantasy dungeon where an ancient gate guardian inspects your player credentials, answers lore questions, and responds to aggression or stealth maneuvers.

• Spatial trigger zones• Persistent quest tracking• Dual-adapter dialogue
Transparent Pricing

Built for Indie Game Economics

Reactions cost fractions of a cent. Our pricing is designed so you never get hit with unexpected viral bills.

Hobby
$0/forever free

Perfect for game jams, prototyping, and indie experiments.

  • ✓10,000 reactions / month
  • ✓Up to 3 distinct NPC characters
  • ✓Persistent player memory
  • ✓Sub-800ms global edge delivery
  • ✓Community Discord support
Start Free
Studio
$199/per month

For commercial studios, multi-player worlds, and publishers.

  • ✓2,500,000 reactions / month
  • ✓Dedicated DITTO / PCL adapter weights
  • ✓Custom safety & content policies
  • ✓Hard SLA guarantees (99.9% uptime)
  • ✓Multi-tenant team collaboration
Contact Studio Team