Docs
Quickstart: your first agent in under an hour
You’ll register one agent, connect one system (Anthropic here), and run the agent so every model call goes through the directory: it carries a badge naming the agent, the real key never leaves CodeBrix, and you can hold or stop it from the console.
You need: a CodeBrix space (https://<space>.codebrix.dev), its owner’s sign-in, the cbx CLI, and an Anthropic API key. Python 3.9+ or Node 18+.
1. Register the agent (console, 2 minutes)
Sign in, open Agents → Directory → Register agent:
- name
support-bot(lowercase, digits, hyphens), kindsdk - owner: you (the person answerable for it; offboarding them pauses it)
- team, purpose, and a monthly budget in USD (calls stop at the budget)
2. Put the key in the vault (CLI, 1 minute)
cbx vault put agents/support-bot/anthropic
The value comes from a hidden prompt, never an argument. Only the directory reads it, at call time; your agent never sees it.
3. Connect the system (console, 3 minutes)
Agents → Directory → Systems → Add system:
- name
anthropic, kindanthropic, base URLhttps://api.anthropic.com - auth: header
x-api-key; key pathagents/support-bot/anthropic - agents:
support-bot - allowed:
POST/v1/messages(add more rules as you need them; anything not allowed is refused) - prices (optional, for the budget): input 3, output 15 USD per million tokens
- connection: connected
Tick hold on a rule to make a person approve each matching call first.
4. Give the agent its secret (console, 1 minute)
On the agent, Make a token (role app). It is shown once:
export CBX_SPACE=<space>
export CBX_AGENT_TOKEN=cbxa_... # the agent's only secret; it is traded for 15-minute badges
No secret at all is possible too: in CI, bind the workload’s OIDC identity to the agent (CBX_AGENT=support-bot, GitHub Actions is detected), or on a laptop use the device flow (Directory.device_login(agent="support-bot"): you approve a code in the console).
5. Run it
Install (until the package is on PyPI and npm, install it from the agents repository: pip install ./sdk/python, npm install ./sdk/node).
Python
from codebrix import Directory
import anthropic
d = Directory() # CBX_SPACE + CBX_AGENT_TOKEN
client = anthropic.Anthropic(base_url=d.system_url("anthropic"), api_key="cbx-badge",
default_headers=d.headers()) # or codebrix.langgraph / adapters below
print(client.messages.create(model="claude-sonnet-5-5", max_tokens=200,
messages=[{"role": "user", "content": "Say hi"}]).content[0].text)
Node
import { Directory } from 'codebrix'
import Anthropic from '@anthropic-ai/sdk'
const d = Directory.fromEnv()
const client = new Anthropic({ baseURL: d.systemUrl('anthropic'), apiKey: 'cbx-badge', fetch: d.fetch })
const msg = await client.messages.create({ model: 'claude-sonnet-5-5', max_tokens: 200, messages: [{ role: 'user', content: 'Say hi' }] })
console.log(msg.content[0].text)
d.headers() is a badge for the next 15 minutes; for long-running Python processes use an adapter, which refreshes it on every request. Node’s d.fetch always does.
Check the console: the call shows under the agent with its tokens and cost.
6. Hold, stop, and lend credentials
- Holds. A call matching a hold rule waits:
d.request("anthropic", "POST", "v1/messages", json=..., reason="why")blocks until someone approves it under Holds waiting, then repeats it once.wait_for_hold=FalseraisesHeldwith the id instead. - Stop. Press Stop for the agent, its team, the system or everyone: the next call raises
Stopped(423).d.watch_stop(on_stop=...)tells you within about 2 seconds, andd.check_stop()raises between steps. - Lent credentials. Systems in broker mode (GitHub App, AWS STS, GCP) hand out short-lived credentials:
d.creds("github"). From a shell:cbx creds git,cbx creds aws.
7. Frameworks
Claude Agent SDK
from codebrix import claude_agent_sdk as cbx
ClaudeAgentOptions(env=cbx.env(d), mcp_servers=cbx.mcp_servers(d, profiles=["github"]),
hooks={"PreToolUse": [HookMatcher(hooks=[cbx.stop_hook(d)])]})
import * as cbx from 'codebrix/claude-agent-sdk'
query({ prompt, options: { env: await cbx.env(d), mcpServers: await cbx.mcpServers(d, { profiles: ['github'] }), hooks: { PreToolUse: [{ hooks: [cbx.stopHook(d)] }] } } })
The Claude Agent SDK runs the Claude Code CLI as a child process, which can’t refresh a badge: ask for a longer one (Directory(ttl_seconds=3600)) and build the options per run.
OpenAI Agents SDK
from codebrix import openai_agents as cbx
cbx.use(d)
Runner.run(agent, input, hooks=cbx.StopHooks(d))
import * as cbx from 'codebrix/openai-agents'
await cbx.use(d)
cbx.stopHooks(d, runner)
LangGraph
from codebrix import langgraph as cbx
model = cbx.chat_anthropic(d, model="claude-sonnet-5-5")
# add cbx.stop_guard(d) as a node
import * as cbx from 'codebrix/langgraph'
await cbx.chatAnthropic(d, { model })
cbx.stopGuard(d)
When something’s refused
| Error | Status | What to do |
|---|---|---|
Stopped / Paused | 423 / 403 | A person stopped or paused it; the message says who and why. Don’t retry another way. |
StopUnreachable | 503 | CodeBrix Stop can’t be reached and the space holds such calls; retry shortly. |
Held / HoldDenied / HoldExpired | 202 | Waiting for, refused by, or timed out on a person’s approval. |
BudgetExceeded | 402 | The agent’s monthly budget is spent; raise it on the agent. |
Refused | 403 / 429 | Not on the allowed list, blocked, or a cap; final. |
BadgeRefused | 401 | Revoked, the agent killed, or a bad token. |