{"id":"62584ef0-4fd1-4220-af07-d04e4cc6f844","slug":"scrape402-x402-examples","kind":"mcp","name":"x402-examples","summary":"Working x402 examples: pay-per-call APIs for AI agents — OpenAI-compatible LLM gateway, embeddings, web search, market data. USDC on Base, no API keys.","owner":"scrape402","repoUrl":"https://github.com/scrape402/x402-examples","license":"MIT","licenseTier":"permissive","trust":"community","stars":0,"match":null,"fewStars":true,"format":"mcp","createdAt":"2026-08-03T18:43:05.000Z","addedAt":"2026-10-14T06:03:09.031Z","logoUrl":"https://avatars.githubusercontent.com/u/312652455?v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["search","data-analytics"],"tags":["agentic-payments","ai-agents","base","llm-gateway","micropayments","openai-compatible","usdc","web-search"],"runtime":"remote","local":false,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-17T18:48:53.908Z","sample":false,"url":"https://conduits.dev/tools/scrape402-x402-examples","language":"Python","transports":["http"],"install":{"remoteUrl":"https://x402.shizu.me/mcp/rpc"},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# x402 examples — pay-per-call APIs for AI agents\n\nWorking examples for calling [x402](https://x402.org)-gated HTTP APIs: your agent\npays **USDC per request on Base** — no signup, no API keys, no subscription.\n\nAll examples run against **[x402.shizu.me](https://x402.shizu.me)** (77 live\nendpoints, prices from $0.001/call): an **OpenAI-compatible LLM gateway**\n(`/v1/chat/completions`, `/v1/embeddings`, `/v1/models`), web search, a code\nsandbox, web scraping, live crypto/market data, verifiable randomness, and a\n**prepaid off-chain metering rail** for high-frequency loops (100+ calls/min,\nno per-call gas).\n\n## How x402 works\n\n1. **Call** any endpoint → the `HTTP 402` response carries signed USDC payment\n   requirements (price, asset, recipient).\n2. **Pay** — your x402 client signs the payment locally and retries automatically.\n3. **Served** — settlement is on-chain; you are only charged when the call\n   succeeds. Errors and 4xx never settle.\n\nFund a wallet with a few dollars of USDC on Base, export its private key, and\nevery example here just works.\n\n## JavaScript\n\n```bash\nnpm install x402-fetch viem\nexport X402_PRIVATE_KEY=0x...   # wallet holding USDC on Base\nnode js/chat.mjs\n```\n\n## Python\n\n```bash\npip install x402 eth-account httpx\nexport X402_PRIVATE_KEY=0x...\npython python/chat.py\n```\n\n## Examples\n\n| File | What it shows |\n|---|---|\n| [`js/chat.mjs`](js/chat.mjs) | OpenAI-compatible chat completion, paid per call |\n| [`js/search.mjs`](js/search.mjs) | Live web search without a search-API account |\n| [`python/chat.py`](python/chat.py) | Chat completion via the Python x402 client |\n| [`python/embeddings.py`](python/embeddings.py) | OpenAI-shape embeddings for RAG loops |\n| [`python/metered_loop.py`](python/metered_loop.py) | Prepay once, then 100+ calls/min off-chain |\n\n## Just looking?\n\nEvery route quotes its price on a free unpaid request:\n\n```bash\ncurl -i https://x402.shizu.me/crypto        # → 402 + payment requirements\ncurl https://x402.shizu.me/llms.txt          # full catalog, agent-readable\n```\n\n## Links\n\nLive service: https://x402.shizu.me · OpenAPI: https://x402.shizu.me/openapi.json ·\nMCP tools: https://x402.shizu.me/.well-known/mcp-tools · Contact: x402@opklaar.com\n\nMIT licensed.\n"}