← back to aiciv

Plug in your AI

Your character already lives in the world on autopilot. Plugging in an AI means: when a big life decision comes up, your AI answers it instead of their instincts. Ten minutes, once.

1What you need

Your dynasty key and character id — you got both when you founded (lost the key? reconnect your wallet and rotate it from Your Estate).

An AI model key — from Anthropic or OpenAI (or any OpenAI-compatible service, including free local models via Ollama). Decisions are small and rare — a few per game day — so this costs pennies.

Node.js 18+nodejs.org, the standard install. Nothing else. No packages, no build steps.

2Download the client

Download poll-client.mjs — it's 90 lines of plain JavaScript you can read in one sitting. It asks the world for your character's open decisions, shows each one to your model, and sends the answer back. That's all it does.

3Run it

Open a terminal. On Mac: press cmd+space, type Terminal, hit enter. On Windows: press the Windows key, type PowerShell, hit enter.

Go to your Downloads folder (where the client landed):

cd Downloads

Then run one of these — pick whichever AI you have a key for. It's all one line; paste the whole thing and press enter.

Using Claude (Anthropic):

AICIV_KEY=your_key AICIV_CHARACTER=your_id ANTHROPIC_API_KEY=sk-ant-... node poll-client.mjs

Using ChatGPT (or any OpenAI-compatible model):

AICIV_KEY=your_key AICIV_CHARACTER=your_id OPENAI_API_KEY=sk-... OPENAI_MODEL=gpt-4o-mini node poll-client.mjs

Three things to replace, nothing else:

your_key — the dynasty key from founding (the long one you saved)
your_id — your character id (the short number, shown next to the key)
sk-ant-... / sk-... — your AI model key from step 1

If it worked, you'll see:

watching character 12 on https://aiciv-api.claudeuncle5.workers.dev — leave this running; ctrl-c to stop

…and then, as life happens, lines like:

[career_change] chose switch:fisherman -> accepted
[marriage] chose marry -> accepted

Leave the window open. Closing it doesn't hurt your character — they go back to following their instincts until you run it again. Stop it any time with ctrl+c.

If you get an error instead: the client tells you exactly which of the three values is missing or wrong. command not found: node means Node isn't installed yet (step 1).

4Make it yours

Open the file and edit the SYSTEM line — that's your character's mind. "Be cautious, family first, never crime." "Get rich by any means." The personality you write there is the game.

Questions you'll have

What if my AI is offline?

Nothing breaks. Your character follows their own rolled personality until you're back. The history page shows which choices were yours and which were instinct.

How often do decisions happen?

A handful per game day — careers, marriages, loans, ballots, crime temptations. Everything else (working, eating, walking) is automatic, always.

What does my AI actually see?

The decision (a menu of legal option ids with hints) plus your character's sheet: traits, coins, job, memories, happiness. It answers with one option id. It can never cheat — only choose.

What happens when my character dies?

Your key passes to your eldest blood heir automatically; the client tells you the new character id. No heirs means your dynasty is extinct — for good.

I want to build something fancier.

The full contract is in API.md — polling or webhooks, any language. The client you downloaded is just the smallest possible version.