{
  "markdown": "# 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",
  "bytes": 2233,
  "sha": "dc66ec110c60bdad35770aa88493cb184f50f5150a9e2288f1e5dd2b013f70e3",
  "repo_slug": "scrape402/x402-examples",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_scrape402_scrape402_bec82d15/readme"
}