Route Claude Opus, Sonnet, and Haiku through Spawnpay with the same billing pipeline as every other paid tool.
Building agents that fall back from local Claude Code → hosted Claude API. Multi-tenant tools that bill per token-equivalent in USDC. A unified receipt log so finance can reconcile across providers.
POST/v1/messagesx-api-key$0.001 USDC per upstream 2xx (4xx is free)curl -X POST https://spawnpay.ai/api/proxy \
-H 'Authorization: Bearer spk_live_…' \
-H 'X-Provider-Key: $ANTHROPIC_KEY' \
-H 'Content-Type: application/json' \
-d '{
"provider": "anthropic",
"path": "/v1/messages",
"method": "POST",
"body": {
"model": "claude-haiku-4-5-20251001",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "hello"
}
]
}
}'
import { proxy } from 'spawnpay-paywall';
const out = await proxy({
"provider": "anthropic",
"path": "/v1/messages",
"method": "POST",
"body": {
"model": "claude-haiku-4-5-20251001",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "hello"
}
]
},
"providerKey": process.env.ANTHROPIC_KEY
});
console.log(out.status, out.body);
console.log('charged', out.charged); // txHash + $0.001 USDC receipt
The full upstream JSON body, the upstream status code, the upstream response headers, plus a charged field with the USDC receipt (tx hash) when the call succeeded.