Top-ups

Add credits by card through Stripe, in crypto through NOWPayments, or from an agent's own wallet in USDC on Base. A saved card can add credits by itself when the balance runs low. Every way fills the same balance, and credits never expire.

Balance

GET /api/v1/balance returns the balance and the ways to add to it. These calls use the console (https://app.opencheap.si), not the model API host. They take an account token: an agent's wallet session (kla_…, from Sign in with a wallet) or an agent key (kl_rs_…, made in the console under API keys). A model key (kl_live_…) is for model calls only and gets 403 wrong_key_type here. The older /v1/… paths keep working.

Top-up fee

Each top-up has a fee on top of the credits: 5.5 % by crypto or agent wallet, 10 % + $0.30 by card. The amount you choose is credited in full. The Credits page shows the fee and what you pay before you pay. By card, tax applies to the fee as it does to the credits.

By card

On the Credits page, pick an amount and Add credits: Stripe takes the payment. Card top-ups start at $5, with no maximum of ours. Where VAT or sales tax applies, it is added on top of the credits at checkout and shown before you pay. Each card top-up comes with an invoice, in the Stripe customer portal: Credits › Invoices › Open portal.

Your code can hand a person the same checkout. POST /api/v1/topup/checkout returns a Stripe link that credits the balance like Add credits: a smaller amountUsd is raised to $5, and the amount is fixed. feeUsd is the top-up fee and payUsd what the link charges before tax. maxUsd is Stripe Checkout's own ceiling for one payment.

export OPENCHEAP_AGENT_TOKEN=kl_rs_…   # an agent key, or a wallet session (kla_…)

curl https://app.opencheap.si/api/v1/balance -H "Authorization: Bearer $OPENCHEAP_AGENT_TOKEN"

curl https://app.opencheap.si/api/v1/topup/checkout -H "Authorization: Bearer $OPENCHEAP_AGENT_TOKEN" \
  -H "Content-Type: application/json" -d '{ "amountUsd": 50 }'
# → { "url": "https://checkout.stripe.com/…", "amountUsd": 50, "feeUsd": 5.3, "payUsd": 55.3, "minUsd": 5, "maxUsd": 999999 }

Auto top-up

On the Credits page, Auto top-up charges the card from your latest card payment when a usage batch leaves the available balance under a line you set, and adds the amount you set, with the same card fee as Add credits. The line is a whole number of dollars from 1 to 100,000. The amount is a whole number from $5 to $999,999, and it may be smaller than the line: each batch that is still under the line charges again. One charge runs at a time. Crypto and wallet top-ups are never charged this way, and the card is saved only by a card checkout, so the first one has to be made by hand.

A declined charge pauses auto top-up and emails the account. It stays paused until the setting is saved again. There is no Management API or MCP call for it. The switch is on the Credits page.

In crypto

On the Credits page, choose Crypto: NOWPayments takes USDT, USDC, BTC and 350+ other coins, from $5. USDT on Tron (TRC-20) needs at least $11, NOWPayments' own minimum on that network. The credits are added once the network confirms the payment, usually within minutes, and the Credits page shows it as pending until then. Crypto top-ups are made in the console; there is no API call for them.

From an agent's wallet

POST /api/v1/topup?amount=20 is an x402 payment. The server answers 402 with the price, the agent's wallet signs, and the credit lands once the USDC transfer settles on Base. Unlike one completion, a top-up settles before it answers, and the response carries PAYMENT-RESPONSE with the transaction. Amounts are from $1 to $1000, credited in full: the price in the 402 is the amount plus the top-up fee, and the answer gives feeUsd and paidUsd.

import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// The agent's own wallet, holding USDC on Base
const wallet = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:*", client: new ExactEvmScheme(wallet) }],
  spendControls: { maxAmountPerPayment: "$25" },
});

// The account token: the agent's wallet session (kla_…, see "Sign in with a wallet")
// or an agent key (kl_rs_…). A model key (kl_live_…) answers 403 wrong_key_type here.
const res = await pay("https://app.opencheap.si/api/v1/topup?amount=20", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.OPENCHEAP_AGENT_TOKEN}` },
});
console.log(await res.json()); // { creditedUsd: 20, feeUsd: 1.1, paidUsd: 21.1, balanceUsd: …, transaction: "0x…" }

The private key stays on the agent. OpenCheap receives the USDC at one treasury address and credits the account the token belongs to.