# Yumina for Games

Put characters in your game that the player can talk to in their own words. They stay in character, react to what is happening in the game, remember what was said **in that save**, and can ask your game to do things — give an item, change friendship, start a quest — which your game checks and applies with its own rules.

- **Free for you.** Players sign in with their Yumina account and their own mushies pay for the AI. You never get an AI bill, and there is no key to hide in your build.
- **Memory follows the save.** Every turn returns a memory id your game stores in its save file. Load an older save and the characters remember exactly that timeline — nothing from a branch the player didn't save.
- **The AI only proposes.** You declare what characters may do, with parameters and limits. Yumina checks every request against that; your game still decides and applies it.
- **Characters anyone can write.** Register your game once, and writers can make characters for it in Yumina Studio. Your game lists them with one call.
- **Any engine.** C# (Unity, Godot .NET, MonoGame, BepInEx / MelonLoader / SMAPI mods), GDScript (Godot), JavaScript (web games, Electron, Node), plain HTTP from anything else, and [Yumina Link](./link) for mods that can only run scripts.

## Five minutes to a talking character

**1. Register your game.** Sign in at [yumina.io](https://yumina.io), open **Developers** from your avatar menu ([yumina.io/app/developer](https://yumina.io/app/developer)), and register your game or mod. You get a `client_id`. Pick a manifest template and talk to a character under **Try it** before you write any code. While the game is in development, only you and the testers you name can sign in to it.

**2. Sign the player in.** On a PC the SDK opens the browser; anywhere else (Steam Deck, consoles, full-screen) show a QR code the player scans with their phone.

```csharp
var yumina = new YuminaClient(new YuminaOptions {
    ClientId = "ym_…",
    TokenStore = FileTokenStore.ForApp("MyGame"),
});
if (!yumina.IsSignedIn) {
    var link = await yumina.StartQrSignInAsync();
    ShowQr(link.Qr, link.UserCode, link.VerificationUri);   // draw link.Qr.IsDark(row, col) as squares
    await link.WaitAsync();
}
```

**3. Talk.**

```csharp
var mira = yumina.Character("mira", CardRef.Inline(miraCardJson));     // or CardRef.Hub(publishedCardId)
var turn = await mira.SayAsync("Morning! Anything warm?",
    inputs: new { hearts = 3, weather = "foggy" }, period: "spring-3",
    onText: line => bubble.Text = line);                                // streams, clean
ShowChoices(turn.Choices);                                              // three replies in the player's voice
```

**4. Apply what the character asked for, and say what happened.**

```csharp
if (turn.Action is { Accepted: true } a && a.Id == "give_item") {
    bool ok = inventory.TryAdd(a.Text("item"));
    mira.Report(turn, ok, ok ? "the player got a coffee" : "backpack full");
}
```

**5. Keep the memory with the save.**

```csharp
save.YuminaMemory = yumina.Memory.Head;      // when the game saves
yumina.Memory.Load(save.YuminaMemory);       // when a save is loaded (null for a new game)
```

That is the whole loop. Next: [how it works](./concepts), the [C# SDK](./dotnet), the [JavaScript SDK](./javascript), or [plain HTTP](./http) for other engines. The [Stardew Valley example](./example-stardew) shows all of it inside a real game.
