Build a pay-per-inference proxy for Bittensor Chutes (Subnet 64). Accept USDC payments on Base and forward requests to Chutes' decentralized AI network.
Use this skill when the user wants to:
User Says/AsksWhat to Do"Create a Chutes proxy"Run x402 create chutes-proxy my-proxy"I want to sell AI inference"Scaffold the proxy, explain the business model"How do I accept payments for AI?"Explain x402 + Chutes, offer to scaffold"Set up Bittensor integration"Run the create command"What models does Chutes support?"List models (DeepSeek, Llama, Qwen, etc.)
bash
npx @primersystems/x402 create chutes-proxy my-ai-proxy
cd my-ai-proxy
npm install
cp .env.example .env
# Edit .env with your Chutes API key and wallet address
npm run dev
bash
pip install primer-x402
x402 create chutes-proxy my-ai-proxy
cd my-ai-proxy
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your Chutes API key and wallet address
uvicorn main:app --reload
text
User Request
|
v
[Your Proxy] -- No payment? --> Return 402 + price
|
v
User signs USDC payment (gasless)
|
v
[Your Proxy] -- Verify payment --> [Primer Facilitator]
|
v
[Chutes API] -- Forward request --> Bittensor Subnet 64
|
v
AI Response returned to user
You pre-pay Chutes with your API credits. Users pay YOU in USDC. You keep the margin.
After scaffolding, edit .env:
VariableDescriptionRequiredCHUTES_API_KEYYour Chutes API key from chutes.aiYesWALLET_ADDRESSYour wallet to receive USDCYesPRICE_PER_1K_TOKENSYour price in USD (default: 0.001)NoFACILITATOR_URLx402 facilitator (default: Primer's)No
cpk_)bash
wrangler login
wrangler secret put CHUTES_API_KEY
wrangler secret put WALLET_ADDRESS
npm run deploy
bash
docker build -t chutes-proxy .
docker run -p 8000:8000 --env-file .env chutes-proxy
fly launch && fly secrets set CHUTES_API_KEY=xxxYour proxy exposes:
EndpointDescriptionPaymentGET /Health checkFreePOST /v1/chat/completionsChat completions (OpenAI-compatible)RequiredGET /v1/modelsList available modelsFree
Any model on Chutes, including:
deepseek-ai/DeepSeek-V3Qwen/Qwen3-235B-A22Bmeta-llama/Llama-3.1-70B-Instructmeta-llama/Llama-3.1-8B-InstructSee chutes.ai for the full list.
The proxy estimates tokens and charges upfront:
text
Price = (estimated_tokens / 1000) * PRICE_PER_1K_TOKENS
Set PRICE_PER_1K_TOKENS higher than Chutes' cost to make margin. Example:
stream: trueWhoWhyAI agent operatorsGive agents paid AI access without API keysAPI resellersWrap Chutes with your branding/pricingPrivacy servicesAI without accounts or KYCBittensor minersAdd stablecoin revenue stream
bash
# Should return 402 Payment Required
curl http://localhost:8787/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Hello"}]}'
# Pay and get response (using x402 CLI)
npx @primersystems/x402 pay http://localhost:8787/v1/chat/completions \
--max-amount 0.01 \
--method POST \
--body '{"messages":[{"role":"user","content":"Hello"}]}'