ai-characters-in-games is a skill from the Summer skill library: a guide your AI agent reads when the task matches, so it builds the good version on the first try. Safe AI characters in published games: no keys in the build, Summer’s player AI gateway, moderation, caps.
When your agent uses it
- A character, creature or object should answer free-form player text or speech in a published game (talking flowers, shopkeepers, companions)
- About to put a model name, a provider SDK or a provider key into a game project
- Handling AI refusals (ai_disabled, age_policy, credits_exhausted, limit_exceeded) or adding the report button for AI replies
- Topping up Summer credits, setting AI limits or the kill switch for a game’s AI characters
Install
summer setup installs every skill for your agent. To add only this one:
claude-code for your agent, such as codex or cursor. See Skills for every option.
The skill
Overview
A talking flower, a shopkeeper who answers questions, a companion who reacts to what the player says. Players, often children, type or speak to it and it answers in character. Core principle: the game never talks to an AI provider. It asks Summer, as the signed-in player, for a reply from a persona the developer declared. Summer holds the keys (you never bring your own), moderates both directions, charges the cost to the developer’s Summer credits and can switch the feature off per game. The game treats every AI answer as optional flavour on top of an offline brain that always works. Status: preview.Summer.client.ai ships with an upcoming Summer Engine release. The example checks for it at runtime and reads the capabilities of status() before using a call, and uses the offline brain whenever either is missing, so a game written this way ships today and gains AI replies when the platform turns them on.
When to use
- A character, creature or object answers free-form player text or speech.
- You are about to put a model name, a provider SDK or a key into a game project. Stop and use this instead.
The rules, and why
Top up and set limits
AI characters are paid from the Summer credits of the developer who turned them on. Cost depends on the models and voices you choose. Your dashboard shows spend as it happens, and your limits cap it. Players never pay. There is nothing to configure in the game project.- In Summer Studio, open the game and its AI characters section.
- Add a persona per character: name, a plain-words description, an optional voice, reply length, a safe line in character, and the model (from the models the game allows, each marked fast or smart).
- Set limits per player per day, per game per day and per month, optional per-model caps, and the refill amount; see your dashboard for the ranges.
- Turn Enable on. Saving makes you the funding developer: Summer moves your credits into the game’s AI balance in refill-sized chunks as it runs low.
- Top up credits from the billing page when the balance is low. Withdraw unused AI credits returns what no call has reserved.
credits_exhausted or limit_exceeded and the game falls back to its offline brain; nothing crashes. Enable off is the kill switch and applies to the next request. Children and players who have not declared an age are excluded.
The SDK
Summer.client.ai exists only on engines that include it; everywhere else it is null. Every method returns a SummerOperation. Await it race-free:
r.ok, r.code and r.retryable say how it went; the answer itself is on the operation, a SummerAIOperation (op.text, op.audio, …), because replies and voice clips are larger than a result’s details. Type it as Object so the script still parses on engines without that class. The engine creates request ids itself.
moderated: true is not an error: the persona’s safe line replaced the answer. Show it like any reply. Names are snake_case in GDScript (op.exchange_id, persona.has_voice). After limit_exceeded or rate_limited, op.retry_after_seconds says when asking again can succeed.
In multiplayer, never broadcast text a client sent you. The dedicated authority verifies the exchange and broadcasts the text Summer returns:
r.ok == false):
Steps
- Write the offline brain first. Keyword intents plus a few lines per personality, deterministic per (character, text) so every client agrees. This is the shipped experience when AI is unavailable.
- Declare personas in the game’s AI characters settings (see Top up and set limits), not in scripts: one per character, a short description in plain words, a safe line in character (“Let’s talk about sunshine instead!”).
- Add the talk UI: a typed box, a hold-to-talk button that only appears when the microphone is allowed, the reply bubble, and a small report button on every AI reply.
- Route through one character script (below): gateway when
statussays available, offline brain otherwise and on every refusal. - Keep effects on the authority. If talking changes something, the authority computes it from the player’s words with the offline rules and clamps it.
- Verify (below).
Example
OfflineBrain.answer(personality, text) is your step 1 script. Keep the report button visible only when exchange_id is not empty, since offline lines are your own text.
Verify
grepthe project for provider names, model ids and anything key-shaped: none.- With the gateway absent (every engine today), every character answers from the offline brain and no error is shown.
- Typed input works with the microphone denied.
- Each failure code in the table leads to an offline answer, and the session-level codes stop further gateway calls.
- With Enable off, or the game’s AI credits withdrawn, the game still plays and every character answers offline.
credits_exhaustedleads to an offline answer with no error shown.- A reply marked
moderatedshows the safe line. - AI replies carry an “AI” label, and the microphone is only used after the player agreed.
- In multiplayer, the authority broadcasts only text returned by
verify_exchange. - A reply never grants items, currency or progress by itself; the authority applies any effect.
- Every AI reply shows a report button that sends its exchange id.
Common mistakes
- Sending the persona description from the client “just for testing”. It ships.
- Treating
moderated: trueas an error. It is a normal reply. - Retrying on
limit_exceededorcredits_exhausted. The limit is the product working. - Putting a provider key in the project “until Summer is live”. There is no bring-your-own-key path; keys in builds leak.
- Letting the model decide rewards because “it only suggests”. It will be talked into suggesting everything.
From a shell
No Summer MCP tools in this session? Run each one as a command; whensummer --version is missing or below 4.0, use npx -y summer-engine@latest in place of summer. Fields are flags in kebab-case (--scene-path res://main.tscn) or one --input '<json>', and summer ops describe <op> prints the exact input. The summer-cli skill has the rest.
Related skills
design-npc: Design enemy, NPC, boss or companion behavior: perception, state machine, telegraphs, script stub.multiplayer-state: Authority-owned state in Summer multiplayer: shared and private State groups, Commands, Events.
Source:
library/skills/ai-characters-in-games/SKILL.md, rendered from summer-engine@4.3.0 on npm.
