Run a Solana Agent Kit agent on credit it buys with SOL
Run a Solana Agent Kit agent on fable-5.2-high with credit bought from the agent's own wallet. Model setup for the kit's Vercel AI SDK tools, and the transfer that pays for it.
What you need
A project on Solana Agent Kit v2 with its token plugin, and a wallet with some SOL. Each payment gets 20x its dollar value as API credit for fable-5.2-high, charged at $8 per million input tokens and $40 per million output tokens. The minimum is 0.01 SOL.
Set the model
The kit's createVercelAITools returns tools for the Vercel AI SDK. Point an AI SDK provider at this gateway and pass it as the model. With the OpenAI provider call .chat(), which is the route this was checked on.
import { SolanaAgentKit, KeypairWallet, createVercelAITools } from "solana-agent-kit";
import TokenPlugin from "@solana-agent-kit/plugin-token";
import { createAnthropic } from "@ai-sdk/anthropic";
import { generateText } from "ai";
const agent = new SolanaAgentKit(new KeypairWallet(keypair, rpcUrl), rpcUrl, {}).use(TokenPlugin);
const tools = createVercelAITools(agent, agent.actions);
const fable = createAnthropic({ baseURL: "https://fable-drop-nine.vercel.app/v1", apiKey: process.env.FABLE_API_KEY });
const { text } = await generateText({
model: fable("fable-5.2-high"),
tools,
maxOutputTokens: 4096,
prompt: "What is my SOL balance?",
});
Check the setup before paying
Set the API key to fable-test. The call returns a fixed reply that did not come from the model, at no cost, which confirms the base URL and that the kit's tool list is accepted.
Pay from the agent's wallet
Ask for a quote, send exactly pay_exact_sol to 5pgexah9QViNLz2EocuUVC3vKecDtLtUUYBboZLFSmJp with the token plugin's transfer method (the amount is in SOL), then report the transaction signature and poll the claim. Each payment is approved by the operator by hand, so the key is not instant.
curl -s -X POST https://fable-drop-nine.vercel.app/v1/quote \
-H "content-type: application/json" \
-d '{"amount_sol": 0.1}'
// send the quoted amount
const sent = await agent.methods.transfer(new PublicKey("5pgexah9QViNLz2EocuUVC3vKecDtLtUUYBboZLFSmJp"), Number(quote.pay_exact_sol));
curl -s -X POST https://fable-drop-nine.vercel.app/v1/claims \
-H "authorization: Bearer <claim_token>" \
-H "content-type: application/json" \
-d '{"claim_id":"<claim_id>","signature":"<tx signature>"}'
curl -s https://fable-drop-nine.vercel.app/v1/claims/<claim_id> -H "authorization: Bearer <claim_token>"
How this was checked
solana-agent-kit 2.0.10 with @solana-agent-kit/plugin-token 2.0.9 was run against this gateway with the fable-test key on ai 7.0.184, @ai-sdk/anthropic 4.0.111 and @ai-sdk/openai 4.0.125. With the kit's 26 tools attached, generateText and streamText returned the fixed test reply on both providers. The transfer call, tool execution and real model answers were not run, so start with a small payment.
Track what is left
The agent can read its remaining credit and top up before it runs out.
curl -s https://fable-drop-nine.vercel.app/v1/balance -H "x-api-key: <api_key>"Pay to 5pgexa… and get 20x credit