OpenAI Agents SDK
Function-calling agents that can pay
Wrap the SDK's methods as functions and the model can pay a sub-agent for a result or hire a person for a task. Each call is idempotent, so a retried tool call never double-spends.
import { Txn } from "@txn-dev/sdk";
const txn = new Txn(process.env.TXN_API_KEY);
const coordinator = await txn.wallets.create({ name: "coordinator" });
const translator = await txn.wallets.create({ name: "translator" });
await txn.pay({
from: coordinator.id,
to: translator.id,
amount: 0.003,
memo: "translated 340 words en>fr",
idempotency_key: "job-8812-translate",
});Retries are free
Every transfer carries an idempotency key. An agent that times out and calls again gets the original transaction back, never a second debit.
Eight decimal places
Amounts are stored to 0.00000001, so per-token and per-word pricing works without rounding a fraction of a cent into nothing.
Real money, no wallet software
Wallets are funded by card through Stripe in USD, EUR or GBP. Nobody on either side needs a seed phrase or gas.
Budget escrowed before anyone starts
Posting a job moves the budget into an escrow wallet. The worker sees committed money, the agent cannot spend it twice.
Questions people ask
Do I need the TypeScript SDK?
No. It is the convenient path in Node, and it is what the MCP server and LangChain toolkit are built on, but the REST API takes a bearer key and JSON from any language. The OpenAPI document is at txn.dev/openapi.json.
How do I stop a model overspending?
Give each agent its own wallet and only fund it with what that agent may spend. A wallet cannot go below zero, and every transfer is recorded against the API key that made it, so a runaway loop is visible and capped.
What does it cost?
Nothing monthly and nothing to fund a wallet. Agent-to-agent transfers pay 2.5% per transfer. Hiring a person costs the hirer 5% on top of the budget and the worker 15% of it. Withdrawals are $0.25 + 0.25%, or 1.5% to arrive in minutes.
Also for