How it works
A character turn is one HTTP call. Your game says who is speaking, what the player said, and what the game knows right now. Yumina runs the character on its servers with the save's memory and answers with the line, three suggested replies, the values your game reads back, and at most one action for your game to apply.
game ──► POST /api/ai/v1/turns { character, card, text, inputs, allow, period, memory.head, results }
◄── { text, choices, outputs, action, memory.head } (or streamed as server-sent events)Your game never sees the card's prompt. That is why any published card made for your game can be played inside it, including ones whose authors keep their lore private — the same as playing them on yumina.io.
The manifest
The manifest is your game's contract with every character in it. Register it on your game's page (yumina.io → Developer → your game → Game manifest); every version is kept.
{
"version": 1,
"game": { "id": "steam:413150", "name": "Stardew Valley" },
"rules": "What every character in this game knows, and how they speak.",
"inputs": [
{ "id": "hearts", "type": "number", "description": "Friendship hearts with the player, 0 to 14.", "example": 3 }
],
"outputs": [
{ "id": "friendship_delta", "type": "number", "min": -20, "max": 20, "description": "Friendship this line earns or costs." }
],
"actions": [
{
"id": "give_item",
"description": "Hand the player something you would plausibly have on you.",
"params": { "item": { "type": "string", "enum": ["coffee", "a daffodil"] } },
"limits": { "perPeriod": 1 }
}
],
"choices": 3
}| Part | What it does |
|---|---|
game.id | steam:<appid>, or a lowercase slug. Cards declare the same id to be playable in your game. |
rules | Shown to every character before their own card: the world, the tone, length limits. |
inputs | What your game sends each turn. The character reads them; it can't change them. example is what Studio playtests with. |
outputs | Numbers, strings or booleans the character sets each turn. Clamped to min/max, reset to default every turn. |
actions | What a character may ask your game to do. Parameters are checked (types, ranges, enum), and so are the limits. |
choices | How many suggested replies to write in the player's voice (0 to 5). |
Card authors write only the person. The manifest adds the plumbing on every turn, so a writer can never break your game by renaming a variable.
While you iterate you can send the manifest with each turn instead (YuminaOptions.Manifest, or manifest in the request); that works for you and your testers with your own cards. Players always run the version Yumina reviewed when it made your game live; newer versions reach only your team until the next review.
Actions: the AI proposes, your game decides
Each turn the character may propose one action. Yumina checks it before you see it:
- Is it an action of this game, with valid parameters?
- Did your game allow it this turn? Send
allow: ["give_item"]to apply your own rules (hearts, story flags, inventory). Leave it out to allow every action;allow: []allows none. - Are its parameters within this turn's range? When what a character can give depends on the moment (what this NPC carries), send
{ "id": "give_item", "params": { "item": { "enum": ["Bandage", "Rice wine"] } } }inallow: the character sees only those, and any other value is refused. Numbers takemin/max. - Is it within its limits?
perConversationcounts this conversation;perPeriodcounts the currentperiodyou send (a day, a week, a run). Both count from the save's own memory, so loading an older save gives the limits back.
The character knows what it can't do this turn, and why. A spent limit, an action your allow leaves out, an empty pocket: the character is told, so it can turn the player down in its own words instead of promising. Send your own reasons in blocked: { "give_item": "you barely know the player" }. Its words and its action must agree: handing something over in words means proposing that action in the same reply, and if it proposes one it may not take, you get rejected and can add a word of narration.
You get action.status = "accepted", or "rejected" with a code and a reason:
code | Meaning |
|---|---|
limit | Used up for this conversation or this period |
not_allowed | Your game doesn't allow it this turn (left out of allow, or in blocked) |
invalid_params | Bad parameters, or a value outside this turn's range |
unknown_action | Not an action in your manifest |
said_not_done | The character's line handed something over without proposing the action (see below) |
Never apply a rejected one, and always handle it: the line may already have promised it, so add a word of narration ("He pats his empty sleeve."). A rejected action keeps the params the character asked for (for said_not_done, the one value of a narrowed parameter that matches what was said, when exactly one does). That turn comes with no suggested replies, since replies written for the promise would carry it on. The character's next line is told it did not happen.
Said, not done. Small models sometimes hand something over in words ("take it") without proposing the action. When your game has actions and a turn proposed none, Yumina reads the line once more with a small model; if it promised one of your actions, you get that action back as rejected with code said_not_done and said (what it handed over, in its words). That check is a small extra call on the player's mushies (about 0.1 to 0.2, an eighth to a quarter of a turn on the default model) and adds a moment before the turn ends. It runs only on turns that proposed no action. For an accepted one, apply it your way, then report what happened — Report(turn, applied, note) — and the next line tells the character. An action you report as not applied does not count toward its limits; one never reported (the player quit first) counts as done.
Memory follows the save
Memory is a chain: each turn points at the one before it. Your game keeps only the newest id — memory.head — in its save file.
- New game: send no head.
- After each turn, store the new head (the SDKs keep it in
Memory.Headfor you). - Load a save: send the head stored in it. With an SDK, call
Memory.Load(head)after loading, before the next line.
Loading an older save hands Yumina an older head, and every character remembers exactly what happened up to that save. A branch the player never saved is never mixed in. One head covers every character in the save.
The memory belongs to the player's Yumina account, so it is the same on every device, and it is deleted with the account. A head from a different account is refused (unknown_head); the SDKs then start that save's memory fresh.
Cards
A character runs a Yumina card: a published one (card: { id }) or your game's own (card: { world: { … } }, up to 256 KB). Your own card can be built at runtime, which is how games with generated characters work: see Characters your game builds. The Stardew example builds each villager's card from the player's installed game, so nothing copyrighted ships with the mod.
Writers make cards for your game in Yumina Studio: this card → Game interface → this card is a character in a game, then your game's id. Published, all-ages cards with your id are listed by GET /cards for an in-game character picker. Until your game is live it plays only cards you or your testers published, and other authors' cards always run under the manifest Yumina reviewed, never one sent inline.
Signing in
Your game is a public OAuth 2.1 client: no secret to protect. Players sign in with Authorization Code + PKCE.
| Where | How |
|---|---|
| PC, Mac, Linux | SignInWithBrowserAsync opens yumina.io and listens on 127.0.0.1:47613–47617 for the code (RFC 8252). |
| Anywhere | StartQrSignInAsync / startQrSignIn returns a QR code (as a grid of squares) and a short code. The player signs in on their phone; the game polls. Use it on Steam Deck, consoles, VR, TVs, or in full-screen. |
| Web games | signInWithRedirect / handleRedirect with your page's https URL added to the game's redirect URIs. |
The SDK keeps a refresh token (encrypted with Windows DPAPI on Windows) and short-lived access tokens in memory. Refresh tokens rotate on every use. Players see your game under Settings → Connected apps and can disconnect it at any time, which ends its access at once.
Who pays
Each turn is charged to the player's own Yumina wallet at the model's real cost, and only when a reply was delivered. Players also earn free mushies from Yumina's daily quests. A turn that fails with insufficient_balance should send the player to account.plansUrl. Players who set their Yumina account to use their own AI key (Settings → AI) play on that key instead, with the model they picked there (the game's model is ignored), and are charged nothing; the turn's yumina.ownKey is true. Cards whose author keeps them on Yumina's models answer such players with card_needs_yumina_models. You pay nothing either way.
Going live
A new game is in development: only you and up to 50 testers (by Yumina username) can sign in, on their own mushies. When it's ready, upload your manifest and submit for review; Yumina checks what characters may do in your game and opens it to every player. Your game's page shows turns, players and model cost for the last 30 days, and the Turn log shows every turn you and your testers played (what your game sent, what came back, what it cost), for finding out why a character did or didn't act. Players' own conversations never show there.
