Client SDK for x402-powered LLM API with automatic payment handling and zkTLS proofs
npm install @reclaimprotocol/llm-x402-clientYou can pay for each request, without having to buy a subscription or credits using USDC on Base Network.
npm install @reclaimprotocol/llm-x402-client
`
$3
`
import { LLMClient } from '@reclaimprotocol/llm-x402-client';
`Call the LLM
`
const client = new LLMClient({
apiUrl: "https://llm-x402.reclaimprotocol.org",
walletPrivateKey: process.env.X402_WALLET_PRIVATE_KEY,
network: 'base',
});
const result = await client.callLlm({
model,
messages: [
{ role: 'user', content: message }
],
});
`$3
You can use a private key that you own on Base Network.
If you don't own one, you can create one using
`
npx create-wallet
`You must then send USDC and some ETH to the above wallet.
Make sure you add the private key to your
.env.local file
`
LLM_API_URL=https://llm-x402.reclaimprotocol.org/api/call-llm
X402_NETWORK=base
X402_WALLET_PRIVATE_KEY=0x...
`$3
Currently supports Anthropic, OpenAI and Google (soon)
You can see supported models on Supported Models pageSelf Hosting
When initializing LLMClient, you can pass your own self hosted x402 server as apiUrl.To self host,
$3
`
$ git clone https://github.com/reclaimprotocol/llm-x402.git
`$3
Set these in the .env file
`
API Keys for LLM Providers
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-proj-...
GOOGLE_API_KEY=AI...x402 Payment Configuration
X402_WALLET_ADDRESS=0x...
X402_NETWORK=baseCDP API Keys for mainnet facilitator
CDP_API_KEY_ID=...
CDP_API_KEY_SECRET=...Reclaim Protocol zkFetch Configuration
RECLAIM_APP_ID=...
RECLAIM_APP_SECRET=...
`
#### Where to get the API Keys
LLM API Keys :
- ANTHROPIC_API_KEY
- OPENAI_API_KEY
- GOOGLE_API_KEYX402_WALLET_ADDRESS CDP_API_KEY_ID & CDP_API_KEY_SECRETRECLAIM_APP_ID and RECLAIM_APP_SECRET#### Run it
`
$ npm run build && npm run start
``