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:
| Answer | What it means | What your agent should do |
| ALLOWED | Safe to go ahead | Do it |
| REQUIRE_APPROVAL | A person must say yes first | Wait |
| BLOCKED | Not allowed | Do 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 see | It means | Do this |
missing X-API-Key | The key was not sent | Run Step 1 again in the same terminal window |
command not found: python3 | Python is not installed | Install it from python.org, then retry |
NO ANSWER YET | The servers took longer than a minute to agree | Run the same box again |
REQUIRE_APPROVAL every time | The action is always high-risk (for example deleting everything, or moving 10,000 or more) | That is on purpose: a person approves each one |