Solana API for AI agents

Your agent signs up with only a Solana keypair, reads one file that lists every error and the action to take, and calls RPC and swap quotes as JSON-RPC on one host. It gets unsigned transactions; signing stays with the wallet you control.

Free to start, with the free Quote plan at 10 quotes a second. Dev from $20 a month.

Four jobs an agent does on its own

Sign up, read, call, quote. Carbium has a surface for each, on one key and one host: services.carbium.sh.

  1. /v1/auth/wallet

    Sign up with a keypair

    A challenge, a proof of work and a signed sign-in message open a free account with one key. No browser and no inbox: the agent reads its key over the API.

    Account and keys
  2. carbium.sh/skill.md

    Read one reference

    One Markdown file, written for agents: every method and limit, every error with the action to take, and complete JavaScript clients to copy.

    carbium.sh/skill.md
  3. services.carbium.sh

    Call one host

    RPC and the quote plane are JSON-RPC over POST, with one key in x-api-key. Subscriptions run over WebSocket on the same host, and Carbon Stream (gRPC) from Dev.

    RPC reference
  4. quote, then swap

    Quote and hand off

    quote finds a route across 17 venue families, and swap answers one unsigned transaction for user_pubkey. The wallet or policy you control signs it.

    Carbium Swap API

The agent asks, your wallet signs

Nothing Carbium returns moves funds on its own. A swap and a plan payment both come back as unsigned transactions, so the signature, and the decision, stay with the wallet or policy you control.

What Carbium returns at each step, and who acts on it
StepWhat Carbium returnsWho acts
Sign upA session and one free key, once the agent signs the sign-in messageThe agent, with its keypair
QuoteA route and a quoteId, good for 30 secondsThe agent
SwapOne unsigned transaction: user_pubkey is the fee payer and only signerThe agent asks; nothing has moved
SignNothing: the private key never reaches CarbiumThe wallet or policy you control
SendA signature, then its status from getSignatureStatusesThe agent, with the signed bytes
Pay for a planAn unsigned USDC or USDT payment, from crypto-intentThe wallet or policy you control

Rules worth giving the agent

  • Sign only as user_pubkey, and never change the transaction
  • Never auto-retry a send: check getSignatureStatuses first
  • Stop on a 4xx: a refused call still spends rate
  • When a task outgrows Free, say so and point to a paid plan

The free plan is a license for one person or one agent, for real work. Its terms bind the agent and the person it works for: more than one free account, or rotating accounts, keys or addresses for more capacity, voids the license and bans every key on the account.

Acceptable use, in skill.md

From a keypair to a key

Six calls on carbium.sh, in four steps, open the account, read the key and add the free Quote plan. The agent needs a Solana keypair and nothing else.

  1. Solve the challenge

    GET /v1/signup/challenge, then find a nonce whose BLAKE3 hash, over the challenge and the nonce, starts with as many zero bits as the difficulty. At 18 bits that is about 262,000 hashes. A challenge lasts 300 seconds and opens one account.

  2. Sign in with the keypair

    POST /v1/auth/wallet twice: once for the message, once with its signature and the proof of work. The message names the Carbium Terms, and signing it accepts them. The session lasts 30 days.

  3. Read the key

    GET /v1/keys lists the starter key, and POST /v1/keys/{id}/secret answers it. A wallet account has no email, so nothing is mailed: the key is read here.

  4. Add the free Quote plan

    POST /v1/modules/quote with the plan free. quote, swap, prices and health then answer on the same key and cost no credits.

onboard.mjs
// Onboard with only a Solana keypair: an account, its key and the free Quote plan
//   npm i @solana/kit @noble/hashes
import { createKeyPairSignerFromBytes, getBase58Decoder, signBytes } from "@solana/kit";
import { blake3 } from "@noble/hashes/blake3.js";
import { readFileSync } from "node:fs";

const call = async (path, { body, session, post } = {}) => {
  const res = await fetch("https://carbium.sh" + path, {
    method: post || body ? "POST" : "GET",
    headers: { ...(body ? { "content-type": "application/json" } : {}),
               ...(session ? { authorization: "Bearer " + session } : {}) },
    body: body ? JSON.stringify(body) : undefined });
  if (!res.ok) throw new Error(path + ": HTTP " + res.status + " " + (await res.text()));
  return res.json();
};

// The proof of work: the first nonce whose blake3(challenge, nonce as 8 little-endian bytes)
// starts with at least difficulty zero bits
function solve(challenge, difficulty) {
  const c = new TextEncoder().encode(challenge);
  const buf = new Uint8Array(c.length + 8);
  buf.set(c);
  const view = new DataView(buf.buffer);
  for (let nonce = 0; ; nonce++) {
    view.setBigUint64(c.length, BigInt(nonce), true);
    let bits = 0;
    for (const b of blake3(buf)) { if (b === 0) { bits += 8; continue; } bits += Math.clz32(b) - 24; break; }
    if (bits >= difficulty) return nonce;
  }
}

const signer = await createKeyPairSignerFromBytes(
  new Uint8Array(JSON.parse(readFileSync(process.env.KEYPAIR, "utf8")))); // solana-keygen JSON
const wallet = signer.address;

// 1. A one-use challenge (good for 300 s), solved here
const { challenge, difficulty } = await call("/v1/signup/challenge");
const nonce = solve(challenge, difficulty);

// 2. The sign-in message names the Carbium Terms: signing it accepts them
const { nonce_token, message } = await call("/v1/auth/wallet", { body: { step: "challenge", wallet } });
const signature = getBase58Decoder().decode(
  await signBytes(signer.keyPair.privateKey, new TextEncoder().encode(message)));

// 3. Verify: a new wallet opens a free account with one starter key
const { session_token } = await call("/v1/auth/wallet", {
  body: { step: "verify", wallet, nonce_token, signature, pow: { challenge, nonce } } });

// 4. Read the key, then add the free Quote plan
const [key] = await call("/v1/keys", { session: session_token });
const { raw_key } = await call("/v1/keys/" + key.key_id + "/secret", { session: session_token, post: true });
await call("/v1/modules/quote", { session: session_token, body: { plan: "free" } });
// raw_key is the agent's API key: store it as a secret (CARBIUM_KEY), never in a log or a prompt
Shortened from "Agents: onboard yourself with only a Solana keypair" in carbium.sh's reference, whose full file also buys a plan in USDC or USDT and makes a first call and a first quote.

Limits on sign-up

One IPv4 address, or one IPv6 /56, opens at most 3 accounts in 24 hours, so sign up from the address the agent will call from. A free account holds 1 key, and its credits are granted once.

Account and keys

Which plan for which agent

Start on Free with the keypair alone. When the agent's work outgrows it, the agent should say so and point to a paid plan, as the terms ask.

  • Free

    $0a month

    One agent, starting out

    A license for one person or one agent: 500K credits once and 5 cached reads a second.

    Requests a second, cached reads
    5
    Requests a second, account reads
    0.5
    Credits, granted once
    500K
    Streams on Carbon Stream
    None
    Live API keys
    1
  • Dev

    Fits an agent at work

    $20a month

    An agent at work

    10M credits a month, 15 account reads a second and Carbon Stream with 5 streams.

    Requests a second, cached reads
    30
    Requests a second, account reads
    15
    Credits a month
    10M
    Streams on Carbon Stream
    5
    Live API keys
    5
  • Business

    $250a month

    Several agents

    10 keys, 50 account reads a second and 50M credits a month.

    Requests a second, cached reads
    100
    Requests a second, account reads
    50
    Credits a month
    50M
    Streams on Carbon Stream
    25
    Live API keys
    10
  • Pro

    $500a month

    Many agents

    50 keys, 400 account reads a second and 200M credits a month.

    Requests a second, cached reads
    500
    Requests a second, account reads
    400
    Credits a month
    200M
    Streams on Carbon Stream
    100
    Live API keys
    50

Plans are bought on carbium.sh. Prices are in US dollars; card through Stripe is the main way to pay. You can also pay in USDC or USDT from your own wallet. The Carbium Swap API runs on the same key: the free Quote plan answers 10 quotes a second, and quotes cost no credits.

What breaks with an agent

Agents fail in a few predictable ways: a key in a log, a send repeated, a retry loop on an answer that will never change.

  • Keep the key in a secret store

    Read it from the environment, never into a prompt or a log, and send the full key in x-api-key. The short c_serv_ prefix is a label and always gets unknown api key.

    API key security
  • Keep the signer apart

    Let the agent quote, build and send, and keep the key that signs in a wallet or policy you control. Sign only as user_pubkey.

    Signing and sending a swap
  • Never auto-retry a send

    Check getSignatureStatuses first. To resend, send the same signed bytes until the block height passes lastValidBlockHeight.

    Blockhash expiry recovery
  • Stop on a 4xx

    A refused call costs no credits but still spends rate. A free account refused for rate in most hours of a day is suspended.

    Errors and retries
  • Parse amounts with BigInt

    Quote amounts are decimal strings in base units. A JavaScript number loses digits above 2^53.

    Quote reference
  • Bound the key

    Lock the key to the agent's addresses with an IP allowlist, and set a per-method cap, such as a ceiling on sendTransaction, below the plan rate.

    Allowlists and caps

Questions

carbium.sh's reference covers every method and limit. For anything else, talk to the team on the Carbium Discord.

The reference, as one file

Can an AI agent get a Solana API key on its own?

Yes, with only a Solana keypair. It fetches a challenge, solves a small proof of work, signs the sign-in message and reads its key, with no browser and no inbox. One IPv4 address, or one IPv6 /56, opens at most 3 accounts in 24 hours.

Account and keys

Is there a Solana API reference an LLM agent can read?

Yes: https://carbium.sh/skill.md, one Markdown file written for agents. It covers sign-up, keys, every method and limit, every error with the action to take, and complete JavaScript clients for RPC, WebSocket, Carbon Stream and swaps.

carbium.sh/skill.md

Does an agent need an SDK or an MCP server?

No. RPC and the quote plane are JSON-RPC over HTTPS on one host, so any HTTP client works, and the standard Solana SDKs (@solana/web3.js, @solana/kit) and Yellowstone gRPC clients work with the endpoint and key set. carbium.sh's reference names no Carbium SDK or MCP server; it gives complete JavaScript clients to copy.

JavaScript clients

How does an agent swap tokens with the Carbium Swap API?

It calls quote with src_mint, dst_mint, amount_in and slippage_bps, then swap within 30 seconds with the quoteId and the signing wallet as user_pubkey. swap answers one unsigned transaction; the wallet signs it, and the agent sends it with skipPreflight and confirms it with getSignatureStatuses. Each swap pays a 0.05% router fee inside that transaction.

Quote and swap

Can an agent pay for a plan in USDC?

Yes, in USDC or USDT on Solana, on carbium.sh. POST /v1/billing/crypto-intent with the plan, 1 to 12 months, the mint and the paying wallet answers an unsigned transaction for that wallet to sign and send. Poll the intent until it reads paid. SOL itself is not taken as payment.

Paying in USDC or USDT

Is the free plan enough for an AI agent?

For one agent's real work at Free limits: 500K credits granted once, 5 cached reads a second and 1 key. Running more free accounts, or rotating keys or addresses for more capacity, voids the license and bans every key. When a task needs more, the agent should say so and point to Dev, from $20 a month.

Compare Carbium RPC plans

What should an agent do when a call fails?

Read the HTTP status, then error.data.reason, then error.code. Retry only what waiting can fix, such as a 429 or a 5xx on a read, after retry-after-ms. Never loop on a 4xx, which still spends rate, and never auto-retry sendTransaction: check getSignatureStatuses first.

Errors and retries

Sign the agent up free, then put it to work on Dev

An agent opens a free account with its keypair and adds the free Quote plan in a few calls. When the work grows, Dev adds 10M credits a month, 15 account reads a second and Carbon Stream, and it can be paid in USDC or USDT.

Read carbium.sh/skill.md