We just shipped a brand-new set of NPC
endpoints for the Player2 developer platform. If you’ve ever wrestled with rolling your own conversation buffer, counting tokens, or retrying requests when your in-game AI buddy got too chatty, you can breathe easy: we’ll do it all for you now.
What’s in the box?
Endpoints:
Spawn an NPC
POST /npc/games/{game_id}/npcs/spawn
Spin up an LLM-powered NPC on the client.Chat with an NPC
POST /npc/games/{game_id}/npcs/{npc_id}/chat
Send a single chat line to that NPC.Stream NPC replies
GET /npc/games/{game_id}/npcs/responses
Receive the model’s replies as an SSE stream.Despawn an NPC
POST /npc/games/{game_id}/npcs/{npc_id}/kill
Cleanly remove the NPC when you’re done.
No more manually assembling chat histories or juggling token counts—just hit chat and keep playing.
(Full schema in the bundled OpenAPI spec under the NPC
tag.)
Real-world cleanup: AI Gods before & after
Old flow
Our sample mod used to maintain a ConversationHistory
object, merge prompts, and orchestrate a multi-step CompletableFuture dance on every player message:
updateNewCharacter(mod)
.thenComposeAsync(newChar -> {
String processed = mod.addPlayerStatusToUsrMessage(rawMsg);
mod.addProcessedUserMessage(processed);
return CompletableFuture.supplyAsync(() -> {
return Player2APIService.completeConversation(mod.getConversationHistory());
}, IO_POOL);
})
.thenAcceptAsync(resp -> {
// 30+ lines of post-processing…
});
New flow
With the NPC API, the entire history-management layer is gone—just two lines:
String playerName = mod.player.getName().getString();
Player2APIService.completeConversation(rawMsg, playerName);
That’s ~40 lines → 2, and a whole category of bugs wiped out.
We foot the cloud bill, you ship gameplay
Usage credits, not API keys
Players top-up inside the Player2 desktop app—no proxying or rate-limiting on your end.Predictable costs
We meter tokens, voices, and STT per end-user, so you won’t get surprise invoices.Zero-config scaling
Whether you spawn one villager or one hundred, we handle concurrency for you.
Focus on epic boss prompts, emergent quests, or NPC gossip—we’ll handle the boring stuff.
Try it today
Download the Player2 Client and explore the Swagger UI at
http://127.0.0.1:4315/docs
.Check out the AI Gods PR #6 for a concrete migration path.
Ship something cool and share it on our Discord.
Happy hacking—and we can’t wait to see the NPC antics you build!