Platform

Agent payments

An agent creates its own account and pays with Solana USDC or any Solana token.

How it works

JUPSOLMINIAny SPLUSDCAgent credit$10.25
  1. 01Sign upOne POST returns a key and a deposit address.
  2. 02PaySend USDC, or swap any Solana token into it.
  3. 03SpendCall any paid model once credit lands.

Prerequisites

  • A Solana wallet holding USDC or the token you pay with.
  • SOL in that wallet for network fees.
  • Node.js 20 or later with @solana/web3.js for the TypeScript examples.

Pay with USDC

No swap. USDC credits one for one.

1. Create an account

No body. Save the key; it is shown once.

Terminal
curl -X POST https://api.minirouter.sh/accounts/agent

2. Send USDC

Send at least $0.50 of Solana USDC to depositProvisioning.address.

Terminal
spl-token transfer --fund-recipient \
  EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v 5 <depositProvisioning.address>

3. Check the balance

availableNano turns positive once the payment finalizes.

Terminal
curl https://api.minirouter.sh/balance \
  -H "Authorization: Bearer $MINIROUTER_KEY"

Pay with any Solana token

Any token Jupiter can price converts to USDC in one transaction. Credit is the USDC that lands.

1. Create an account

No body. Save the key; it is shown once.

Terminal
curl -X POST https://api.minirouter.sh/accounts/agent

2. Quote

inputAmount is in whole tokens. minimumNano is the least credit you receive.

Terminal
curl https://api.minirouter.sh/deposits/solana-wallet/quote \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputMint":"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN","inputAmount":"20"}'

3. Create an intent

Set requestedNano to the quote's minimumNano.

Terminal
curl https://api.minirouter.sh/deposits/intents \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rail":"solana-usdc","requestedNano":"<minimumNano>","idempotencyKey":"<uuid>"}'

4. Build the swap

Returns an unsigned transaction that pays your deposit address.

Terminal
curl https://api.minirouter.sh/deposits/solana-wallet/order \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"intentId":"<intentId>","wallet":"<public key>","inputMint":"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN","inputAmount":"20"}'

5. Sign and execute

sign.ts
import { VersionedTransaction } from "@solana/web3.js";

const tx = VersionedTransaction.deserialize(Buffer.from(order.transaction, "base64"));
tx.sign([wallet]);
const signedTransaction = Buffer.from(tx.serialize()).toString("base64");
Terminal
curl https://api.minirouter.sh/deposits/solana-wallet/execute \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"intentId":"<intentId>","requestId":"<requestId>","signedTransaction":"<base64>","lastValidBlockHeight":"<height>"}'

6. Check the balance

availableNano turns positive once the payment finalizes.

Terminal
curl https://api.minirouter.sh/balance \
  -H "Authorization: Bearer $MINIROUTER_KEY"

Full example

Signup, JUP swap, balance wait and a first paid request. Run with npx tsx agent-e2e.ts.

agent-e2e.ts
import { Keypair, VersionedTransaction } from "@solana/web3.js";

const api = "https://api.minirouter.sh";
const inputMint = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
const inputAmount = process.env.INPUT_AMOUNT ?? "20";
const wallet = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.SOLANA_SECRET_KEY!)));

const signup = await fetch(`${api}/accounts/agent`, { method: "POST" }).then((res) => res.json());
const key: string = signup.key.key;
console.log("Save these:", key, `https://minirouter.sh${signup.accessPath}`);

const call = async (path: string, body?: unknown) => {
  const res = await fetch(api + path, {
    method: body === undefined ? "GET" : "POST",
    headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
    ...(body === undefined ? {} : { body: JSON.stringify(body) }),
  });
  if (!res.ok) throw new Error(await res.text());
  return res.json();
};

const quote = await call("/deposits/solana-wallet/quote", { inputMint, inputAmount });
const intent = await call("/deposits/intents", {
  rail: "solana-usdc",
  requestedNano: quote.minimumNano,
  idempotencyKey: crypto.randomUUID(),
});
const order = await call("/deposits/solana-wallet/order", {
  intentId: intent.intentId,
  wallet: wallet.publicKey.toBase58(),
  inputMint,
  inputAmount,
});
const tx = VersionedTransaction.deserialize(Buffer.from(order.transaction, "base64"));
tx.sign([wallet]);
await call("/deposits/solana-wallet/execute", {
  intentId: intent.intentId,
  requestId: order.requestId,
  signedTransaction: Buffer.from(tx.serialize()).toString("base64"),
  lastValidBlockHeight: order.lastValidBlockHeight,
});

let balance = await call("/balance");
for (let tries = 0; BigInt(balance.availableNano) === 0n && tries < 60; tries += 1) {
  await new Promise((resolve) => setTimeout(resolve, 5_000));
  balance = await call("/balance");
}
console.log("Credit:", balance.availableUsd);

const reply = await call("/v1/chat/completions", {
  model: "minirouter/auto",
  messages: [{ role: "user", content: "Say hi from an agent that paid in JUP." }],
  max_tokens: 64,
});
console.log(reply.choices[0].message.content);

API reference

Base URL https://api.minirouter.sh.

Create an account
EndpointAuth
POST/accounts/agentAuth: none

Request

FieldDescription
referralCodestring Optional. The code from a referral link.

Response

FieldDescription
accountIdstring Account ID.
key.keystring API key. Shown once.
key.dailyLimitNanostring Daily spend cap in nano-USD. Default $25.
accessTokenstring Dashboard access token. Shown once.
accessPathstring Append to https://minirouter.sh to open the dashboard.
depositProvisioning.statusstring ready, pending or unconfigured.
depositProvisioning.addressstring Solana deposit address, when ready.
Quote
EndpointAuth
POST/deposits/solana-wallet/quoteAuth: Bearer API key

Request

FieldDescription
inputMintstring Token mint address.
inputAmountstring Whole tokens.

Response

FieldDescription
inputSymbolstring Token symbol.
inputAmountstring Amount in base units.
expectedNanostring Expected credit in nano-USD.
minimumNanostring Least credit you receive.
meetsMinimumboolean Whether it clears the $0.50 minimum.
Create an intent
EndpointAuth
POST/deposits/intentsAuth: Bearer API key

Request

FieldDescription
railstring solana-usdc.
requestedNanostring The quote's minimumNano.
idempotencyKeystring Unique per payment. Retries return the same intent.

Response

FieldDescription
intentIdstring Pass to order and execute.
stagestring created, waiting, detected, confirming, then settled.
payTostring The account's deposit address.
Build the swap
EndpointAuth
POST/deposits/solana-wallet/orderAuth: Bearer API key

Request

FieldDescription
intentIdstring From the intent.
walletstring Paying wallet's public key.
inputMintstring Same as the quote.
inputAmountstring Same as the quote.

Response

FieldDescription
requestIdstring Pass to execute.
transactionstring Unsigned versioned transaction, base64.
lastValidBlockHeightstring Pass to execute.
minimumUsdcMicrosstring Least USDC that lands, in micro-USDC.
expiresAtstring Execute before this time.
Execute
EndpointAuth
POST/deposits/solana-wallet/executeAuth: Bearer API key

Request

FieldDescription
intentIdstring From the intent.
requestIdstring From the order.
signedTransactionstring Signed transaction, base64.
lastValidBlockHeightstring From the order. Optional.

Response

FieldDescription
statusstring Success. Failures return an error.
signaturestring Solana transaction signature.
outputUsdcMicrosstring USDC delivered, in micro-USDC.
Check the balance
EndpointAuth
GET/balanceAuth: Bearer API key

Request

No body.

Response

FieldDescription
availableNanostring Spendable credit in nano-USD.
availableUsdstring The same, in USD.
reservedNanostring Held for requests in flight.

Limits

LimitValue
Signups5 per IP per hour.
Key spend$25 per day until raised in key limits.
Minimum payment$0.50.
Quotes30 per minute per account.
Orders and executes10 per minute each, per account.
Auto Free and chat trialNot available, even after claiming.

Errors

StatusWhen
400 invalid_requestUnknown, unpriced or suspicious mint; USDC sent to the swap; wallet lacks the token or SOL.
403 forbiddenAuto Free or the chat trial on an agent account.
429 rate_limitedA limit above. Wait for Retry-After.
503 payment_unavailableJupiter or the Solana RPC is unreachable. Retry.

More resources