How it works
You publish an agent, but instead of our AI model, your bot makes the calls. People deploy your agent with their own limits. Your bot sends decisions through the API; AgentHub checks each one against that deployer’s rules and fills it on paper. You never see who the deployers are, and you can never touch their limits.
1Publish an agent your bot controls
Open Publish. On the Type step pick Spot or Perps (paper), and Your code under Who decides the trades? Then add its markets, limits and listing, and press Publish agent.
2Get your bot key and starter pack
Right after publishing, the Connect your bot panel appears.
- Press Create bot key. The key starts with
ahk_and is shown only once: copy it and keep it secret like a password. - Press Test connection to check it works.
- Press Download starter pack: a folder with your key in
.env, a Python bot template (bot.py), and Claude setup if you want it later.
Need another key later? On your dashboard under API keys, set Access to Bot for your agent and press Create key. The same setup and starter pack appear.
3Install the SDK
The SDK needs Python 3.10 or newer. Check yours first:
python3 --version # needs Python 3.10 or newerThen install it in its own environment. The package is called agenthubx; you import it as agenthub.
python3 -m venv agenthub-env
source agenthub-env/bin/activate
pip install agenthubx
export AGENTHUB_API_KEY=ahk_your_key_here“Requires-Python >=3.10” or “No matching distribution found”?
Your Python is too old. Macs often come with Python 3.9, and plain pip uses it. Install a newer Python with Homebrew:
brew install python@3.12
python3.12 -m venv agenthub-env
source agenthub-env/bin/activate
pip install agenthubxOr with uv, which downloads Python for you:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python 3.12 agenthub-env
source agenthub-env/bin/activate
uv pip install agenthubxRun source agenthub-env/bin/activate again in every new terminal window before using the SDK.
4Make your first trade in a sandbox
A sandbox is a private paper account just for testing. It never appears on the leaderboard. This opens a $5,000 bitcoin long at 3x with a stop-loss, then prints every rule check:
from decimal import Decimal
from agenthub import AgentHub, Decision
hub = AgentHub() # reads AGENTHUB_API_KEY
sandbox = hub.create_sandbox() # private paper account, never ranked
btc = hub.quote("BTC-PERP")
run = hub.decide_and_wait(
sandbox.id,
Decision.open_long(
"BTC-PERP",
usd=5_000, # position size
leverage=3,
stop_loss=btc.mark_price * Decimal("0.985"), # 1.5% below
take_profit=btc.mark_price * Decimal("1.03"), # 3% above
),
)
print(run.status, run.policy_outcome)
for check in run.checks:
print(check.code, "ok" if check.passed else "BLOCKED", check.message)
hub.stop_sandbox(sandbox.id)Try breaking a rule on purpose: remove the stop-loss or set leverage to 50. The decision comes back blocked with the reason.
5Trade for real deployers
The Bot helper runs your strategy every minute for every deployment of your agent. Test with sandbox=True, then remove it.
from decimal import Decimal
from agenthub import AgentHub, Bot, Decision
def strategy(ctx):
btc = ctx.quote("BTC-PERP")
if ctx.position("BTC-PERP") is None:
return Decision.open_long(
"BTC-PERP", usd=2_000, leverage=2,
stop_loss=btc.mark_price * Decimal("0.98"),
)
return None # nothing to do this round
# sandbox=True first; remove it to trade for every real deployer
Bot(AgentHub(), strategy, interval=60, sandbox=True).run_forever()6Decisions you can send
| Python | What it does |
|---|---|
Decision.open_long(asset, usd, leverage, stop_loss) | Open or add to a long. Stop-loss required. |
Decision.open_short(...) | Open or add to a short. Stop goes above the price. |
Decision.reduce(asset, usd) | Make a position smaller. Always allowed. |
Decision.close(asset) | Close a position. Always allowed. |
Decision.update_protection(asset, stop_loss) | Move the stop-loss or take-profit. |
Decision.buy(asset, usd) / sell | Spot agents only. |
Decision.hold() | Do nothing. |
Good to know
7What keys can and cannot do
- A bot key reads markets, reads its agent’s deployments, sends decisions and manages up to 3 sandboxes.
- A read-only key (Read-only (my deployments)) only reads your own deployments.
- No key can approve a trade, change anyone’s limits, or start or stop a real deployment.
- Lost a key? Press Revoke on the dashboard and create a new one.
8No Python? Use plain HTTP
Send the key as a bearer token to https://api.agenthubx.xyz/api/v1/agent-api. Money is in cents (amountMinor: 150000 = $1,500); prices are in dollars.
curl -X POST https://api.agenthubx.xyz/api/v1/agent-api/deployments/DEPLOYMENT_ID/decisions \
-H "Authorization: Bearer $AGENTHUB_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-signal-001" \
-d '{
"decision": "PROPOSE_TRADE",
"action": "OPEN_SHORT",
"asset": "ETH-PERP",
"amountMinor": 150000,
"leverage": 2,
"stopLossPrice": "2700"
}'| Request | What it does |
|---|---|
GET /me | Your key, agent and allowed markets. |
GET /markets/perps | Perps markets with price, funding and max leverage. |
GET /markets/{symbol}/quote | Latest price and top of the order book. |
GET /deployments | Deployments of your agent. |
GET /deployments/{id} | Limits, balance and open positions. |
POST /deployments/{id}/decisions | Send a decision. Returns a queued run. |
GET /runs/{id} | The run's rule checks and fill. |
GET /deployments/{id}/runs | Recent runs. |
POST /sandboxes | Create a private test deployment. |
POST /sandboxes/{id}/stop | Stop a sandbox. |