smartnpcs.com • v0.1

NPCs that react to your game

Report an event, get back a behaviour your game loop can switch on — with player memory, moderation, and hard spend caps. No server to run, no secrets in the browser. Try it live below.

Grom the Blacksmith
ID: smith • Live worker inference
… Contacting worker
Trigger Game Event
Client Received Reaction[…]
Grom:

Contacting live worker…

Mood:—
Action Enum:null
World state:Unsigned demo event (advisory)
{
  "behaviour": null,
  "say": null,
  "action": null,
  "degraded": 0
}
Client SDK

One Import. 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, reputation, and decisions across sessions without running a database. Raw dialogue is purged after 30 days; distilled facts and disposition persist.

Anti-Cheat Authority Boundary

The NPC returns validated behaviour intents and never touches game state. Client world data is advisory prompt context only — opt-in HMAC signing is available for games that need verified state.

Zero-Secret Public Key

Use pk_live_... keys right inside your client-side JavaScript. Vendor API keys stay on our servers and never ship to the browser.

Hard Spend Caps & Predictability

Set a strict daily spend limit per game, enforced before each request against a worst-case cost reservation. Past the cap, NPCs degrade to idle or block — they never bill past it.

Latency Budget With Fallback

Reactions target an 800ms p95 budget; every failure path degrades to a playable fallback instead of throwing. Repeat situations answer from the behaviour cache in milliseconds.

Measurable Invariant Evals

Scored against R1–R5 invariants (validity, appropriateness, consistency, diversity, latency) — deterministic gates run on every deploy, and judge-scored tiers run on demand wherever vendor keys are configured.

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✅ Cross-session working memory keyed by player id (raw dialogue purged after 30 days)
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❌ Full model call on every event, no cache, no fallback✅ 800ms p95 budget; cache repeats in milliseconds, degraded fallback on failure
Runnable Examples

See It in Real Game Loops

Two runnable examples in the monorepo: one wired to the real client SDK, one standalone UI prototype with canned reactions. Clone the repo and run them locally.

Real client SDK

Shopkeeper Barter & Theft Demo

Interact with a gruff medieval blacksmith over the real @npc/client: bargaining, item trade, and what happens when a player draws a weapon or tries to steal an enchanted potion. The page calls /v1/* on its own origin and the demo server proxies those paths to a local worker, so running both commands below gives live inference — without the worker, the SDK answers with its offline fallback.

• Event-in, behaviour-enum-out• Live behaviour, mood & dialogue• Cached repeat barters
pnpm --filter @npc/shopkeeper-demo start
pnpm --filter @npc/worker run serve
Simulated UI prototype

Dungeon Guardian RPG Demo

A dark fantasy dungeon where an ancient gate guardian inspects your player credentials and responds to aggression or stealth maneuvers. Standalone page: its reactions are canned in-page and it makes no worker calls — run it to preview the interaction patterns, not live inference.

• Reputation meter that moves• Canned guardian dialogue• Runs fully offline
pnpm --filter @npc/dungeon-rpg start
Transparent Pricing

Built for Indie Game Economics

Events cost fractions of a cent. Our pricing is designed so you never get hit with unexpected viral bills. Between Hobby and Pro, Pay As You Go bills $2 per 1k events with no base fee.

Hobby
$0/forever free

Perfect for game jams, prototyping, and indie experiments.

  • ✓5,000 events / month
  • ✓Up to 3 NPCs · 2 games
  • ✓Persistent player memory
  • ✓Hard daily spend cap ($10 max)
  • ✓Community support
Start Free
Studio
$199/per month

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

  • ✓1,000,000 events / month
  • ✓Unlimited NPCs & games
  • ✓Custom multi-project spend caps
  • ✓Everything in Pro
  • ✓Dedicated support
Contact Studio Team