Skip to content

Quick start

A web game that already calls an OpenAI-compatible model can be on Playium in an afternoon. You keep your code, your hosting and your domain; Playium handles the player's account, their credits and the model calls.

1. Open a developer account

Sign in to the store, choose a display name on your account page if you have not, then open the developer console. Create a creator (the name players see as the maker of your games) and a game in it. A new game is a draft: only the members of its creator can see and play it.

2. Add the SDK

With a bundler:

shell
npm install @playium/sdk

Without one, use the single-file build. Download it from https://playium.games/sdk/ and copy it into your project:

FileUse it withTypes
playium.mjsimport { Playium, PlayiumError } from './playium.mjs': ES modules, any bundler or noneplayium.d.mts
playium.js<script src="playium.js"></script>, then the global Playiumplayium.d.ts, with playium.d.mts next to it
playium.min.jsThe same, minifiedThe same
playium-testing.mjsA fake store for your tests in Node. See Testing.playium-testing.d.mts

Until the package is on npm

The @playium organisation on npm is being set up. Until the package is published, download the files above and keep them in your project, as you would any script; the first line of each names its version. playium.mjs is the same build as the npm package, with the same exports, so every example in these pages works with from './playium.mjs' in place of from '@playium/sdk'. Do not load the files from the store's address at run time: a copy keeps the version you tested with. No dependencies; about 17 kB gzipped.

3. Connect and call the model

main.js
import { Playium } from '@playium/sdk';

// The handshake with the store: play tokens, refreshing them, retries and store notices.
const playium = await Playium.init();

const reply = await playium.chat({
  messages: [
    { role: 'system', content: 'You are a talking door. Answer in the player\'s language.' },
    { role: 'user', content: 'Knock, knock.' },
  ],
  max_tokens: 100,
});
showAnswer(reply.text);

playium.player;                               // { id }: the player's id in this game
await playium.save.set('progress', { room: 3 }); // a cloud save for this player and game

Already using the openai package? Change one line: new OpenAI(playium.openaiOptions()). See Model calls.

Opened outside the store, Playium.init() rejects with a not_on_platform error. Show the SDK's standard notice with Playium.renderNotOnPlatform(element, { gameSlug }), which links to your store page, or your own. Your game's slug is shown next to its title in the console. See SDK reference for what init() may reject with and when to call it again.

4. Test it on the real platform

Run your game locally as usual, for example on http://localhost:5173. On your game's page in the console, open Preview: the store frames your local address exactly as it frames a published game, with real play tokens, and checks the connection for you. Model calls are paid with your own credits. See Testing.

5. Fill in the listing and submit it

Write the store page (title, description, what the model does, pictures, languages), point it at the https address your game is served from, and submit it. We review it and publish it, usually within a few days. See Listing and review.

Next: SDK reference