OpenAI Agents SDK
agent402-openai-agents · npm · MIT
Tools for agents built with the OpenAI Agents SDK (@openai/agents). Pass them to new Agent({ tools }) and the agent can find, route to and call any tool in the catalog.
Install
npm install agent402-openai-agents @openai/agents zod
Example
import { agent402Tools } from "agent402-openai-agents";
import { Agent, run } from "@openai/agents";
const tools = await agent402Tools(); // free tier: proof-of-work, no wallet
const agent = new Agent({
name: "x402-agent",
instructions: "Use agent402 to find and call paid web tools when needed.",
tools,
});
const result = await run(agent, "Hash 'hello world' with sha256");
What it exposes
agent402_find: a plain-language task in, the best-matching tools out (slug, route, price, input schema, a ready example).agent402_route: ranks tools across every indexed x402 seller;include: "external"leaves this server out.agent402_call: calls a tool by slug and pays for it.agent402_about: the service manifest (payment options, capability map, MCP connector).agent402ToolSpecs()returns the same four as framework-agnostic specs (name, description, JSON Schema, execute) with no framework dependency.
How payment works
- Pure-CPU tools:
agent402_callfetches a proof-of-work challenge and solves it in-process, so no wallet is needed. - Wallet-only tools: pass
fetch, a payment-wrapped fetch.@x402/fetchpays in USDC over x402 on whichever chain your wallet is funded for; a stockmppxfetch pays over MPP. - Unpaid lookups (find, route, about) use
fetchImpland never spend anything.
const tools = await agent402Tools({ fetch: payFetch }); // an x402- or MPP-wrapped fetch
A call that fails is not charged: settlement runs after the tool and only on a successful response. Background: What x402 is · MPP (Machine Payments Protocol).
Tools to try first
Hash$0.001
hash
Web search$0.02
search
Web answer$0.08
answer
Extract article$0.010
extract
Route and execute$0.01
route-execute
Every tool, price and input schema: the catalog.
Links
agent402-openai-agents on npm · source on GitHub · configuration reference
Guides: Use Agent402 from Claude Code, Cursor, VS Code, Windsurf, Cline, Roo Code, Codex CLI, Gemini CLI, Muse Code, Continue, ElizaOS, AgentCore and any OpenAI SDK · One payment, any proven seller: the x402 Smart Order Router
All integrations