The one prompt that makes a vibe-coded game multiplayer
Paste this into Cursor, Claude Code, GitHub Copilot, Windsurf, Replit Agent, Lovable, Bolt or any assistant that can fetch a URL. It works on a game the agent just generated as well as on an existing codebase.
Add online multiplayer to my game with the Multiplayer API (https://multiplayerapi.com). Read https://multiplayerapi.com/llms-full.txt first — it is the complete reference. Then create a game with POST https://multiplayerapi.com/v1/games using the preset that matches my genre, and wire the SDK into my client: guest login, quickmatch, positions over room.send(), and health and score in shared state.
The agent needs nothing else. llms-full.txt is a single self-contained reference — every route, rule, recipe and failure mode — written so a model does not have to guess. openapi.json gives it the machine schema for the same routes.
Why AI-built games stay single-player
Ask an agent to “make it multiplayer” with no backend and you usually get one of three results, none of which ships:
- A Socket.IO or WebSocket server that works on
localhostand then needs a host, a process manager, TLS, scaling and someone to restart it at 3 a.m. - A hand-rolled WebRTC setup that forgets signaling, NAT traversal and the relay for players behind strict networks — so it works between two tabs and fails between two homes.
- A database used as a game server, polling or writing positions sixty times a second, with a bill that grows with every player and no protection against a modified client.
The Multiplayer API removes the server from the problem. It is a hosted HTTP + WebRTC service with a 7 KB JavaScript SDK, so the only code the agent writes is game code: log the player in, join a room, send positions, write health.
What the agent does, step by step
Reads the reference
One fetch of
llms-full.txt. The mental model fits in a paragraph: three channels, declarative rules, a single sync loop.Creates the game — no account needed
POST /v1/gameswith a name and a preset (realtime_arena,turn_based,coop,strict) returns a public key for the client and a secret key for your server. The sandbox runs 2 live rooms for 24 hours; claim it to your console when you subscribe.Wires the SDK
One import from the CDN,
mp.login()for an instant guest account,mp.quickmatch()for a room, then the three channels. No build step, no dependency, no server file.You open two tabs
Load the game twice and watch the second player appear in the first. Send the link to a friend: WebRTC connects you directly, with an automatic relay when it cannot.
The code an agent should write
This is the complete realtime loop — nothing omitted. If your agent writes something much longer, point it back at the reference.
import { Multiplayer } from 'https://multiplayerapi.com/sdk/mp.esm.min.js';
const mp = new Multiplayer({ key: 'mp_pk_...', displayName: 'Player' });
await mp.login(); // instant guest account
const room = await mp.quickmatch({ mode: 'ffa', max_players: 8 });
room.on('members', (members) => syncAvatars(members));
room.on('peer', (p, from) => others[from]?.moveTo(p.x, p.y)); // direct channel
room.state.watch('players.*.hp', (hp, path) => drawHealth(path, hp));
setInterval(() => room.send({ x: me.x, y: me.y }), 50); // positions, P2P
room.mine('hp', 100); // health, validated
Three rules that keep AI-generated netcode correct
| Channel | Call | Delivery | Use it for |
|---|---|---|---|
| Direct | room.send(data) | peer-to-peer, best effort, zero server cost | positions, aim, animation |
| State | room.set(path, value) | server-validated, kept for the match, reaches late joiners | health, score, whose turn |
| Events | room.emitEvent(topic, data) | ordered, guaranteed, not persisted | chat, rematch, one-shots |
The most common mistake in generated code is routing positions through shared state. The reference says so explicitly, and the server's rules reject the worst abuses — a client cannot award itself points it is not allowed to write.
Works with the tools people actually use
Cursor, Claude Code, Copilot, Windsurf
Paste the prompt in the agent panel. The agent fetches the reference, calls /v1/games from the terminal and edits your files.
Lovable, Bolt, Replit, v0
Browser games generated as web apps take the ES module import as-is. No server component to deploy alongside.
Browser-game makers
Anything that outputs HTML5 + JavaScript — Phaser, Three.js, Babylon.js, PixiJS or plain canvas — can add the SDK with a single script tag.
Unity, Godot, custom
The Unity package, or JSON over HTTP with an OpenAPI 3.1 schema for everything else. One key serves every build.
Not affiliated. Tool names are trademarks of their owners and are listed for compatibility only: the integration relies on nothing more than fetching a URL and editing JavaScript.
Why this matters now
AI game generation turned “make a game” from a months-long project into a prompt. The result is a wave of small, fun, single-player browser games — because multiplayer has always needed infrastructure that a prompt cannot provision. The games people remember are the ones they play with friends. An API an agent can set up on its own closes that gap: the same afternoon that produced the game can produce the online version.
Pricing is built for that pattern too: one flat subscription at $19.99/month covers every game in your console, so shipping ten experiments costs the same as shipping one.
Next: pick your engine — Phaser, Three.js, vanilla JavaScript, Godot or Unity — or read how to make a multiplayer browser game.
Can an AI agent really set up multiplayer without me creating an account?
Yes. POST /v1/games is unauthenticated and returns working keys. The sandbox game runs 2 live rooms for 24 hours, which is enough to build and test. You subscribe and claim the game to your console when you want to ship.
Which AI coding tools does this work with?
Any tool that can fetch a URL and edit code: Cursor, Claude Code, GitHub Copilot, Windsurf, Replit Agent, Lovable, Bolt, v0 and others. Nothing is tool-specific; the agent reads llms-full.txt and writes standard JavaScript or C#.
Do I need to deploy a server next to my AI-generated game?
No. The game stays a static site. Positions travel peer-to-peer over WebRTC, and the hosted API handles accounts, rooms, shared state, signaling and the relay fallback.
Is AI-generated multiplayer code safe against cheating?
Shared state is validated by declarative rules on the server, so a modified client cannot write what the rules forbid. Match results can require countersignatures from the other players. Presets such as strict ship sensible rules from the first commit.
How much does it cost to put many small AI games online?
$19.99 per month covers every game in your console, with up to 128 players per room and 2,000 live rooms per game. There is no per-game, per-seat or per-message fee.
Make your game online today
Free sandbox keys in one call, no account and no card. $19.99/month when you ship, for every game you make.
Free sandbox · $19.99/mo to go live · cancel anytime