You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Template repo for AI agents that pay for x402-gated resources using Routex multi-chain settlement routing. Clone this to build agents that automatically handle HTTP 402 Payment Required by selecting the cheapest blockchain and signing payments non-custodially.
This is a starter template, not a library. Clone it, configure .env, and modify src/agent.ts for your use case. The template includes a local x402 test server, a complete agent implementation with Routex routing, typed configuration, and a non-custodial viem-based signer.
## Source Files
- [src/agent.ts](https://github.com/routexcc/x402-agent-starter/blob/main/src/agent.ts): Main agent — requests x402 resource, receives 402, routes payment via Routex, gets resource
- [src/server.ts](https://github.com/routexcc/x402-agent-starter/blob/main/src/server.ts): Local x402 test server returning 402 Payment Required
- [src/config.ts](https://github.com/routexcc/x402-agent-starter/blob/main/src/config.ts): Typed environment config with strict validation
- [src/signer.ts](https://github.com/routexcc/x402-agent-starter/blob/main/src/signer.ts): Non-custodial viem wallet signer for Routex
## Related
- [Routex](https://github.com/routexcc/routex): The multi-chain settlement cost router this template uses
- [@routexcc/core on npm](https://www.npmjs.com/package/@routexcc/core): Router engine package
- [x402 Protocol](https://www.x402.org): The payment protocol standard