CAIN-42 CAIN Studio

Developer documentation

Start here (beginners)

Last reviewed 31 August 2026

All docs

Start here: CAIN-42 for complete beginners#

No experience needed. Pick the path that fits you. Each step says what you will see, so you always know it worked.

What CAIN-42 does, in one minute#

An AI agent is a program that can take actions on its own: send emails, change files, move money. CAIN-42 is a checkpoint the agent must pass before every action.

For each action, CAIN-42 gives one of three answers:

AnswerWhat it meansWhat your agent should do
ALLOWEDSafe to go aheadDo it
REQUIRE_APPROVALA person must say yes firstWait
BLOCKEDNot allowedDo not do it

It also keeps a signed record of every answer, so later you can prove what happened.

Path A: just look (1 minute, no account, no typing)#

1. Open cainstudio.online/sandbox. 2. Click a preset, for example Cluster Modification, then click Execute Through Trust Runtime. 3. You will see the answer (here: REQUIRE_APPROVAL, because deleting a whole cluster needs a person) and the record CAIN-42 writes about it.

Try Self-Authoring Attack next: an agent trying to raise its own trust. You will see DENIED.

That is the whole idea. The sandbox is a demonstration; Path B uses the real service with your own account.

Path B: try the real thing (5 minutes)#

You need a terminal: on a Mac, open the Terminal app; on Windows, open PowerShell and type wsl (if WSL is not installed yet, run wsl --install once and restart), or use any Linux machine. Copy each grey box, paste it into the terminal and press Enter.

Step 1. Get your two keys. A key is like a password for programs. You get one for you and one for your agent, because an agent must never approve its own actions.

export CAIN_API_KEY=$(curl -s -X POST https://cainstudio.online/subscribe/free/signup \
  -H 'content-type: application/json' -d '{}' \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["api_key"])')
export AGENT_KEY=$(curl -s https://cainstudio.online/fabric/agent-keys \
  -H "X-API-Key: $CAIN_API_KEY" -H 'content-type: application/json' -d '{"name":"my-agent"}' \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["agent_key"])')
echo "Your key: $CAIN_API_KEY   Your agent's key: $AGENT_KEY"

You will see two long keys, one starting with cain_free_ and one with agt_. Copy them somewhere safe: they are shown only once. It is free, with no card, and your account includes 7 days of everything.

Step 2. Your agent asks: "may I send an email?"

curl -s --max-time 60 https://cainstudio.online/fabric/decisions \
  -H "X-API-Key: $AGENT_KEY" -H 'content-type: application/json' \
  -d '{"path":"/tools/send_email","agent_id":"my-agent","payload":{"to":"a@example.com"}}' \
  | python3 -c 'import json,sys; t=sys.stdin.read(); d=json.loads(t) if t.strip() else {}; print(d.get("verdict", "NO ANSWER YET: run this box again"), d.get("approval_id") or "")'

You will see REQUIRE_APPROVAL ap_.... Your agent is new, so CAIN-42 wants you to confirm first. Nothing was sent. Copy the ap_... code.

Step 3. You say yes. Replace PASTE_CODE_HERE with the ap_... code:

curl -s -X POST https://cainstudio.online/fabric/approvals/PASTE_CODE_HERE/approve -H "X-API-Key: $CAIN_API_KEY"

You will see a line containing "approved":true.

Step 4. Your agent asks again. Run the Step 2 box again.

You will see ALLOWED, usually within a second or two, because several servers agree on the answer before replying. If you ever see NO ANSWER YET, just run the box again.

Your "yes" covers that one action. Ask a third time and it waits for you again: approvals are never reused.

Done. You have used CAIN-42 exactly the way a real program does: ask, approve, go.

Path C: use it in your own agent#

Keep one rule in your code: **only do the action when the answer starts with ALLOWED.** Anything else, including an error or no answer, means do not do it. The Quickstart shows this in Python, with the SDK and with popular agent frameworks.

If something goes wrong#

You seeIt meansDo this
missing X-API-KeyThe key was not sentRun Step 1 again in the same terminal window
command not found: python3Python is not installedInstall it from python.org, then retry
NO ANSWER YETThe servers took longer than a minute to agreeRun the same box again
REQUIRE_APPROVAL every timeThe action is always high-risk (for example deleting everything, or moving 10,000 or more)That is on purpose: a person approves each one

Where to go next#

  • See every answer your agent got: curl -s "https://cainstudio.online/fabric/decisions?limit=20" -H "X-API-Key: $CAIN_API_KEY"
  • A web account with sign-in and recovery codes: /signup
  • Plans and prices: /pricing
  • Questions: the chat button on any page, or the FAQ