How to Run an AI Trading Agent on Hyperliquid Safely
Set up an AI agent to trade Hyperliquid perps with limits it can't override: API wallets, safe defaults, approving rules, placing orders and closing positions.
Hyperliquid is a natural fit for AI trading agents: deep perpetual markets, an onchain order book, and an API built for automation. Hand an agent the controls, though, and it can open positions at speed and size you'd never choose yourself. This guide walks through a setup where the agent can trade freely inside limits you set, and can't get past them.
It covers two layers: what Hyperliquid itself gives you, and how to add enforced trading limits on top using Pakt.
What Hyperliquid gives you: API wallets
Hyperliquid separates your master wallet, which holds your funds, from API wallets (also called agent wallets). An API wallet can trade on behalf of your account but can't withdraw (Hyperliquid). Withdrawals and transfers need a separate signature from your master wallet, and you can revoke an API wallet at any time.
That's a strong first layer. If an API wallet's key leaks, the funds can't be sent off Hyperliquid.
But an API wallet has the full trading power of your account. It can open any market at any leverage the venue allows, as large as your margin supports. An agent that decides to go hard on leverage can build a position where a small move against it liquidates the account. If the agent driving it makes a mistake, hits a bug or is manipulated by text it reads, nothing stops the order. For an autonomous agent, you need limits on the trades themselves.
The safe setup at a glance
- The agent never holds a key. It proposes orders; it can't sign them.
- Your limits are checked before anything is signed: markets, size, leverage and account-level risk.
- Only passing orders are signed, and the signed order is what gets sent to Hyperliquid.
- Withdrawals stay with your master wallet, which the agent never touches.
- You can always close positions with reduce-only orders.
Here's how to set that up with Pakt. Pakt is non-custodial: your funds stay in your Hyperliquid account, and Pakt never submits orders itself.
Step 1: Create your account and connect Hyperliquid
Sign up at usepakt.ai. On sign-in, Pakt sets up your Pakt signer, which you control and use to approve rules. It also attaches a separate restricted signer that can sign only orders that pass your rules.
New accounts start with a conservative default Pakt already active. It allows BTC, ETH and HYPE perpetuals, at up to $50 per trade and 1x account leverage. It refuses new positions once equity falls below $10, and never moves collateral out.
From the dashboard, select Connect Hyperliquid, choose your Hyperliquid wallet and approve. Your Hyperliquid master wallet authorizes Pakt's restricted signer as its trading agent, using the same API-wallet permission described above. So it can trade but not withdraw, and you can revoke it from Hyperliquid at any time.
Pakt is in beta. If you see the early-access screen, your access is still pending.
Step 2: Connect your AI agent
For Claude Code or Codex, run the installer:
curl -fsSL https://usepakt.ai/install.sh | bash
You can read the installer first. For other MCP-compatible agents, add a remote MCP server with the URL https://api.usepakt.ai/mcp and sign in.
To check it worked, ask your agent: "Show me the Pakt templates available to my account."
The agent gets tools to draft rules, check context and propose orders. It doesn't get a private key, and it can't approve or change your rules.
Step 3: Set limits that fit your strategy
Tell your agent how much you're allocating, which markets you want, and your risk appetite. It drafts a Pakt, a set of concrete limits such as:
- Markets: for example, only BTC and ETH perpetuals.
- Trade-size cap: the largest single order, in dollars.
- Leverage cap: checked against your whole account after the trade, not just the order.
- Concentration, reserve and equity floor: how much can sit in one asset, and the cushion the agent can't trade away.
- Price protection: how far from the reference price an order may fill.
Review the readable summary of the rules carefully. The draft does nothing until you approve it.
Step 4: Approve the rules yourself
An account has one active Pakt at a time. Disable the default from your dashboard and wait 30 seconds. Then ask your agent to prepare your new Pakt for activation. You get a dashboard review link (valid for six hours). Check the rules once more and approve with your Pakt signer.
This approval is the step only you can take. Your agent can draft and propose, but activation always needs your signer.
Step 5: Let the agent trade
From here, your agent prepares orders and asks Pakt to authorize them. A good habit for the first few trades:
- Ask the agent to show the exact order (market, side, size, limit price) before requesting authorization.
- Tell it to request authorization and submit only if signed.
- Ask it to report Pakt's decision and Hyperliquid's result separately. "Signed" means Pakt approved the order; the fill is up to the market.
Pakt currently authorizes immediate-or-cancel (IOC) perpetual orders, and you can bundle up to 10 in one request. Each check takes under two seconds.
If an order breaks a rule, it's refused: no signature is released and the order never reaches Hyperliquid. A refusal is final; the agent can't retry its way past it. If you want different behavior, change the rules deliberately.
Step 6: Closing positions
Limits shouldn't trap you in a losing trade. To close, have the agent prepare a reduce-only order for the position. When it genuinely reduces an existing position, it skips the size, budget, price-band and account-risk limits, so you can always exit. Market and side permissions still apply.
What this setup does and doesn't protect
It protects against an agent opening the wrong market, oversizing, over-leveraging, concentrating the account, trading through your reserve, or moving funds out, whether the cause is a mistake, a bug or prompt injection.
It doesn't make a strategy profitable, close positions for you when the market moves, or replace your judgement about what limits to set. Limits apply per request, not as a rolling daily budget. Start small and adjust as you see how your agent behaves.
FAQ
Can an AI agent trade on Hyperliquid?
Yes. Agents can trade through Hyperliquid's API, usually via an API wallet. Tools like Pakt let agents such as Claude Code and Codex trade within limits you approve.
Is a Hyperliquid API wallet safe?
It can trade but not withdraw, which protects against theft. It doesn't limit size, leverage or markets, so add trading limits for an autonomous agent.
Does the agent ever get my private key?
Not with this setup. The agent proposes orders; Pakt signs only those that pass your limits.
Can I stop the agent instantly?
You can disable your Pakt from the dashboard, and revoke the trading permission from Hyperliquid at any time.
Which Hyperliquid markets are supported?
Eligible USDC-collateral perpetual markets, including HIP-3 markets. Spot trading isn't supported yet.