Docs

Quickstart

Five steps from a wallet to an agent that pays for its own API calls, inside a limit you set.

What you need

ThingWhy
A Solana walletIt owns the panel and the money. It signs when you open, fund or change a budget, and at no other time.
Some USDC and a little SOLThe USDC funds the budget. The SOL pays the network fee and the rent of the accounts a budget opens; closing the budget returns the rent.
Node 22The SDK runs on Node 22 and ships as an ES module.
A service that charges over x402Any API that answers 402 Payment Required with a Solana exact price in the budget’s mint.

Open a panel

Go to your panel, connect the wallet that will own the money, and press Open panel. You sign one transaction. The panel is the root of your budgets: one per wallet, at an address derived from the wallet itself.

If you go straight to New budget with no panel yet, the panel and the first budget open in the same transaction.

Add a budget

Press New budget and fill five things.

FieldWhat to putLater
LabelA name for the agent, 1 to 64 bytes. It shows in the panel and in the ledger.Fixed for the budget.
Agent keyGenerate one here, or paste the public key of a keypair you already hold.Replace it with Rotate key.
LimitThe most the key can pay in one period, in USDC.Change it with Change.
PeriodAn hour, a day or a week. The first period starts when the budget opens.Change it with Change.
ExpiryOptional. A time after which the key pays nothing.Change or clear it with Change.
FundingHow much USDC to put in now. It can be more or less than the limit.Add with Fund, take back with Withdraw.

The review shows the funding, the fee, what reaches the budget, and exactly what the key will be able to do. Sign once. The budget is live from that transaction: the money is in an account the budget owns, and the key is approved to move up to the limit out of it.

A generated agent key is shown once. Copy it or download it before you leave the page. It holds no SOL and no USDC, and it can only pay from this budget.

Install the SDK

npm i https://breaker.to/sdk/breaker-sdk-0.4.0.tgz

One function, breaker(). It needs two values from the confirmation screen: the budget’s address and the agent key.

# .env
BREAKER_BUDGET=<the budget's address>
BREAKER_AGENT_KEY=<the agent key, as copied or as the downloaded file's contents>

The one-line call

Wrap the budget and its key, then use fetch the way you already do. The confirmation screen and the budget’s page both give you this snippet with your address filled in.

import { breaker } from '@breaker/sdk'

const agent = breaker({
  budget: process.env.BREAKER_BUDGET,
  key: process.env.BREAKER_AGENT_KEY,
})

const res = await agent.fetch('https://api.example.com/search?q=solana')
const data = await res.json()

When the service answers 402 Payment Required, the SDK reads its price, checks the budget, pays from it and sends the request again. Your code sees one call and one response. A response that needs no payment passes straight through, so the same agent.fetch can stand in for every request the agent makes.

Run it

Run the agent. Each payment lands in the budget’s ledger within seconds, with the service it went to, and the meter in the panel fills as it does.

When the limit is reached

When a price is above what remains of the limit, the call throws BudgetTripped before anything is signed, and the panel shows the budget tripped until it rolls into its next period or you reset it.

import { BudgetTripped, BudgetOff } from '@breaker/sdk'

try {
  await agent.fetch(url)
} catch (e) {
  if (e instanceof BudgetTripped) console.log('resets at', e.resetsAt)
  else if (e instanceof BudgetOff) console.log('switched off by the owner')
  else throw e
}

Let the agent see its budget

const s = await agent.status()
console.log(s.state, s.remaining, 'of', s.limit, 'until', s.periodEnd)

Where to go next

PageRead it for
BudgetsWhat every control in the panel does to the agent’s next payment.
SDKEvery option, the status fields, the errors and patterns for agents.
x402The exchange with the service and the exact transaction the SDK signs.
ProgramAccounts, instructions, events, errors and addresses on chain.
APIReading panels, budgets and payments over HTTP, and the live event stream.
FeesThe one fee, its arithmetic and where it goes.