Skip to content

Add chat-x402 template#803

Open
phquand2000 wants to merge 3 commits into
Merit-Systems:masterfrom
phquand2000:feat/chat-x402-template
Open

Add chat-x402 template#803
phquand2000 wants to merge 3 commits into
Merit-Systems:masterfrom
phquand2000:feat/chat-x402-template

Conversation

@phquand2000
Copy link
Copy Markdown

@phquand2000 phquand2000 commented May 13, 2026

Closes #610

Adds a new chat-x402 template that combines the next-chat UI with wallet-based payments via the x402 protocol.

Users can authenticate with Echo credentials (automatic billing) or connect a Web3 wallet and pay per request in USDC through the x402 flow.

What's included

  • Dual auth: Echo sign-in or RainbowKit wallet connection
  • x402 payment gate on /api/chat — returns 402 with payment requirements for wallet users
  • Client-side payment signing via createPaymentHeader (adapted from sora-template)
  • Auth guard and modal for the connect flow
  • Provider stack: Wagmi → React Query → RainbowKit → Echo
  • .env.example with WalletConnect and x402 config vars

Template structure

Based on next-chat with additions from sora-template:

  • Shared files (ai-elements, ui components, config) are identical copies from next-chat
  • Auth components (auth-guard, auth-modal, connect-button, connection-selector) adapted from sora-template
  • createPaymentHeader.ts adapted from sora-template (.tsx → .ts)

Test plan

  • npx echo-start@latest --template chat-x402 scaffolds correctly
  • Echo sign-in flow works and chat sends requests with automatic billing
  • Wallet connect flow works via RainbowKit
  • Wallet user gets 402 response, signs payment, and retries with x-payment header
  • Model selector switches between gpt-4o and gpt-5

New template combining next-chat's AI chat UI with x402 payment
protocol support. Users can authenticate via Echo credentials
(automatic billing) or connect a Web3 wallet for per-request
USDC payments through the x402 flow.
The .env.local file contained a real Echo App ID and should
never be committed. Added .env*.local pattern to .gitignore.
- Fix architecture tree in README (remove duplicate src/ prefix)
- Update stale model references (gpt-5-nano → gpt-5)
- Remove nonexistent Dockerfile from deployment section
- Simplify auth-modal auto-close to match sora pattern
- Remove TODO comment from route handler
- Update metadata description
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 13, 2026

@phquand2000 is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat x402 template

1 participant