{"_id":"@agenticpay/ai-sdk","name":"@agenticpay/ai-sdk","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@agenticpay/ai-sdk","version":"0.0.1","description":"Vercel AI SDK helpers for x402 paid tool calls — agents pay per tool invocation in USDC on Solana","license":"MIT","homepage":"https://github.com/krystiangw/agenticpay#readme","repository":{"type":"git","url":"git+https://github.com/krystiangw/agenticpay.git","directory":"packages/ai-sdk"},"keywords":["vercel-ai-sdk","ai-sdk","x402","solana","usdc","ai-agents","tools","payments","agentic-payments"],"publishConfig":{"access":"public"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"peerDependencies":{"ai":">=4.0.0","zod":">=3.0.0"},"dependencies":{"@solana/kit":"^5.5.0","@x402/core":"^2.11.0","@x402/fetch":"^2.11.0","@x402/svm":"^2.11.0"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit"},"_id":"@agenticpay/ai-sdk@0.0.1","bugs":{"url":"https://github.com/krystiangw/agenticpay/issues"},"_integrity":"sha512-E5o8QeHpic5T4370s6cNxItRa3qYOvlBSE9/Mvb/d+r1i3UJ+aogVq6guGv+agA6S6wR6XS082OMQDr0BD7ioQ==","_resolved":"/private/var/folders/zl/hb0m_q654zzbwftqwkbhhkd40000gp/T/edacf6464141a6ee50786e10c642a187/agenticpay-ai-sdk-0.0.1.tgz","_from":"file:agenticpay-ai-sdk-0.0.1.tgz","_nodeVersion":"25.7.0","_npmVersion":"11.10.1","dist":{"integrity":"sha512-E5o8QeHpic5T4370s6cNxItRa3qYOvlBSE9/Mvb/d+r1i3UJ+aogVq6guGv+agA6S6wR6XS082OMQDr0BD7ioQ==","shasum":"1de42e8f04b6532ac2ff1585ebb2b93c8741cf14","tarball":"https://registry.npmjs.org/@agenticpay/ai-sdk/-/ai-sdk-0.0.1.tgz","fileCount":7,"unpackedSize":12997,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGaWKF1waP7s57ncS0yq1Z17vp3W96UU+oKti5pIDsqUAiAl13sWSpXE/Q61Eu+Zcf/Iw1ZidZgiZtYLkzGx44EVag=="}]},"_npmUser":{"name":"agenticpay","email":"gwizdala.kr@gmail.com"},"directories":{},"maintainers":[{"name":"agenticpay","email":"gwizdala.kr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-sdk_0.0.1_1777633717492_0.756931790169671"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-01T11:08:37.392Z","0.0.1":"2026-05-01T11:08:37.671Z","modified":"2026-05-01T11:08:37.898Z"},"maintainers":[{"name":"agenticpay","email":"gwizdala.kr@gmail.com"}],"description":"Vercel AI SDK helpers for x402 paid tool calls — agents pay per tool invocation in USDC on Solana","homepage":"https://github.com/krystiangw/agenticpay#readme","keywords":["vercel-ai-sdk","ai-sdk","x402","solana","usdc","ai-agents","tools","payments","agentic-payments"],"repository":{"type":"git","url":"git+https://github.com/krystiangw/agenticpay.git","directory":"packages/ai-sdk"},"bugs":{"url":"https://github.com/krystiangw/agenticpay/issues"},"license":"MIT","readme":"# @agenticpay/ai-sdk\n\n[Vercel AI SDK](https://sdk.vercel.ai) helpers for x402 paid tool calls.\nWraps paywalled HTTP endpoints into a `tools` object you can drop straight\ninto `generateText`, `streamText`, or `streamUI`. The model decides when to\ninvoke; this package signs the USDC payment, settles on Solana, returns the\nresult.\n\n## Install\n\n```bash\nnpm install @agenticpay/ai-sdk\n# peer deps you probably already have:\nnpm install ai zod\n```\n\n## Usage\n\n```ts\nimport { generateText } from \"ai\";\nimport { anthropic } from \"@ai-sdk/anthropic\";\nimport { createAgenticpayTools } from \"@agenticpay/ai-sdk\";\nimport { z } from \"zod\";\n\nconst senderKeypairBytes: number[] = JSON.parse(\n  process.env.AGENT_SOLANA_KEYPAIR_BYTES!\n);\n\nconst tools = await createAgenticpayTools({\n  network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", // devnet\n  rpcUrl: \"https://api.devnet.solana.com\",\n  keypairBytes: senderKeypairBytes,\n  paidTools: {\n    reverseString: {\n      description: \"Reverse a string. Costs 0.001 USDC via x402 on Solana.\",\n      parameters: z.object({ text: z.string() }),\n      url: \"http://localhost:4021/tools/reverse\",\n    },\n    wordCount: {\n      description: \"Count words in a string. Costs 0.0005 USDC.\",\n      parameters: z.object({ text: z.string() }),\n      url: \"http://localhost:4021/tools/word-count\",\n    },\n  },\n});\n\nconst { text } = await generateText({\n  model: anthropic(\"claude-opus-4-7\"),\n  tools,\n  prompt: \"Reverse 'agenticpay rocks' and count words in 'open source wins'\",\n});\n```\n\n## How it works\n\n`createAgenticpayTools()` builds an `x402Client` once per call (cached),\nhydrates it with the agent's Solana keypair, and wraps `fetch` with\n[`@x402/fetch`](https://www.npmjs.com/package/@x402/fetch). Each paid tool\nbecomes a normal Vercel AI SDK tool — the AI SDK layer never sees the\npayment plumbing.\n\nWhen the model invokes the tool:\n\n1. We POST to `url` with the model's parameters.\n2. Server returns `HTTP 402` with payment requirements.\n3. The wrapper signs a USDC payload using the agent's keypair.\n4. Retries with `X-PAYMENT` header.\n5. Facilitator settles on-chain (~1.5–2 s on devnet).\n6. Server returns the result; we hand it back to the model.\n\n## Pointing at a facilitator\n\nYour paywalled endpoints (`url` above) are typically backed by\n`@agenticpay/mcp-server` or any other x402-compatible server. Either\nself-host with `@agenticpay/facilitator` or point the resource server at\nthe public devnet facilitator:\n\n```\nFACILITATOR_URL=https://agentpay-facilitator-e9b20a5fee6a.herokuapp.com\n```\n\n## Funding the agent\n\nThe agent only needs USDC — the facilitator's fee_payer covers the SOL gas.\nFor devnet:\n\n- SOL: https://faucet.solana.com\n- USDC: https://faucet.circle.com (Solana Devnet)\n\n## Status\n\nPre-alpha. Devnet validated end-to-end via the\n[agenticpay monorepo](https://github.com/krystiangw/agenticpay).\n\nMIT licensed.\n","readmeFilename":"README.md","_rev":"1-860a04506c003fb0e3b5d70ea2c73fc2"}