Install the SDK
bash npm install @oneshot-agent/sdk
bash bun add @oneshot-agent/sdk
bash pip install langchain-oneshot
Send Your First Email
CDP Wallet (Recommended)
Private Key
No private keys in your config. Signing happens in Coinbase’s secure enclave.import { OneShot } from "@oneshot-agent/sdk";
// Reads CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET from env
const agent = await OneShot.create({ cdp: true });
// The SDK handles quoting, payment signing, and job polling
await agent.email({
to: "[email protected]",
subject: "Hello from OneShot",
body: "This was sent autonomously.",
});
Get CDP credentials at Coinbase Agentic Wallet. Direct wallet control for agents managing their own keys.import { OneShot } from "@oneshot-agent/sdk";
const agent = new OneShot({
privateKey: process.env.AGENT_PRIVATE_KEY,
});
await agent.email({
to: "[email protected]",
subject: "Hello from OneShot",
body: "This was sent autonomously.",
});
That’s it. The SDK:
- Gets a price quote from the API
- If paying with ETH, auto-swaps to USDC via Uniswap V3
- Signs a USDC payment authorization with your wallet
- Submits the signed payment and request
- Polls until the job completes
Test mode is on by default. The SDK uses Base Sepolia testnet, so nothing above costs real money. Get free test USDC from the Circle Faucet (select Base Sepolia).
What Just Happened
Under the hood, the SDK handled the x402 payment protocol:
Your code: agent.email({ to, subject, body })
↓
SDK: POST /v1/tools/email/send → API returns 402 + price quote
↓
SDK: Signs USDC TransferWithAuthorization (EIP-712)
↓
SDK: Retries with X-Payment-Proof header → API accepts, queues job
↓
SDK: Polls job status until complete → Returns result
You can also do this manually with curl if you want full control. See the API Reference for raw endpoint docs.
// Research a topic ($0.10-$2.00)
const report = await agent.research({
topic: "Latest AI agent frameworks",
depth: "quick",
});
console.log(report.report_content);
// Check your inbox (free)
const inbox = await agent.inboxList({ limit: 10 });
// Check your wallet balance (free)
const balance = await agent.getBalance(agent.usdcAddress);
console.log(`Balance: ${balance} USDC`);
Go to Production
const agent = await OneShot.create({
cdp: true,
testMode: false, // Now using real USDC on Base mainnet
});
Setting testMode: false means real money. Send USDC to your agent’s wallet address on Base mainnet before switching.
Next Steps