Solrouter
Development

Agent Tools SDK

Typed tools for the Solrouter Agent Privacy API with a Vercel AI SDK adapter. Enable AI agents to execute privacy-preserving on-chain swaps on Solana.

If you want an AI agent to swap tokens on Solana without leaking who is trading what, you normally have to wire up quoting, signing, mixing, and settlement yourself. @solrouter/agent-tools removes that work: it gives you typed tools for the Solrouter Agent Privacy API (/agents/v1) so your agent can quote, execute, and settle privacy-preserving swaps and encrypted inference out of the box.

It ships with a first-class Vercel AI SDK adapter, so you drop it into your agent without writing an orchestration layer. Not on the AI SDK? The raw TOOLS (JSON Schema definitions) and the callTool() function are also exported, so any function-calling framework works — you're never locked into a single AI runtime.

Installation

Add the package with your usual package manager.

npm install @solrouter/agent-tools
yarn add @solrouter/agent-tools
pnpm add @solrouter/agent-tools

Vercel AI SDK quickstart

This is the fastest path: let an LLM decide when to swap, and let the adapter handle the plumbing. Pass aiSdkTools(solrouter) straight into generateText or streamText — it wires up the tool schemas, validates the model's arguments, and marshals results back for you.

import { generateText } from "ai";
import { SolrouterAgentClient } from "@solrouter/agent-tools";
import { aiSdkTools } from "@solrouter/agent-tools/ai-sdk";

const solrouter = new SolrouterAgentClient({
  apiKey: process.env.SOLROUTER_API_KEY,
});

const result = await generateText({
  model: yourModel, // any AI SDK model provider
  tools: aiSdkTools(solrouter),
  prompt: "Privately swap 0.01 SOL to USDC and send the USDC to AAA...XXX",
});

Direct usage (no LLM)

Sometimes you don't want a model in the loop — you want to drive the privacy pipeline yourself in code. Mode B one-shot swaps do exactly that. Your agent signs the funding transaction with its own wallet, then Solrouter runs the 7-step mixer, the Jupiter swap, and the forward-to-destination pipeline.

import { SolrouterAgentClient } from "@solrouter/agent-tools";

const client = new SolrouterAgentClient({ apiKey: "sk_solrouter_..." });

const session = await client.swapOneshot({
  payerPubkey: "...",
  fromMint: "So11111111111111111111111111111111111111112",   // SOL
  toMint:   "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",   // USDC
  amount: "10000000",
  destinationPubkey: "...",  // fresh address — no on-chain link to payer
});

// Sign session.fundingTx with your wallet, broadcast, then:
await client.swapOneshotExecute(session.sessionId, fundingTxSig);
const settled = await client.pollUntilSettled(session.sessionId);

Authentication modes

How your agent proves it can pay shapes how you deploy it, so pick the model that fits before you build. The Agent Privacy API supports two.

  • API key — Include Authorization: Bearer sk_solrouter_... in every request. Usage bills against your prepaid balance in USDC or $ROUTER. Best when your agent is long-lived and you've already funded an account.
  • x402 (keyless) — Pay per call in USDC on Solana mainnet through the Coinbase facilitator, with no account at all. Discover pricing and payment endpoints at /.well-known/x402.

x402 is ideal for agents that operate without a pre-registered API key — for example, autonomous agents that spin up on demand and pay for exactly the calls they make. No balance top-up or account creation required.

Available tools

These are the building blocks your agent can call, whether through aiSdkTools() or the raw TOOLS / callTool() exports. Each one maps to a single step of the private-swap or encrypted-inference flow.

ToolDescription
umbra_quoteQuote a private swap with anonymity-set sizing
umbra_anonymity_setInspect current anonymity set for a mint pair
umbra_swap_oneshotOne-shot swap session — agent signs funding tx
umbra_swap_oneshot_executeSubmit signed funding tx to start execution
umbra_session_statusPoll session state until settled
umbra_create_walletProvision a managed Umbra wallet for an agent
umbra_swap_managedRun a swap from a managed wallet
umbra_encryptConvert balance to encrypted balance on same wallet
umbra_shieldMixer round-trip → withdraw → forward to fresh address
umbra_balanceRead encrypted balance of a managed wallet
umbra_attestationFetch the on-chain attestation PDA for a session
private_inference_paidx402-paywalled encrypted inference (no API key)

On this page