Authentication
BlockRun uses wallet-based authentication via the x402 protocol. Instead of API keys, you sign payments with your wallet.
How It Works
- No API Keys - Your wallet IS your authentication
- Local Signing - Private key never leaves your machine
- Pay-Per-Request - Each request is individually authorized
Setting Up Your Wallet
1. Create or Use an Existing Wallet
You can use any EVM-compatible wallet:
- MetaMask
- Coinbase Wallet
- Rainbow
- Any wallet that can export a private key
2. Fund Your Wallet with USDC
You need USDC on the Base network to pay for API requests.
Getting USDC on Base:
- Bridge from Ethereum using the Base Bridge
- Buy directly on Coinbase and withdraw to Base
- Swap on a DEX like Uniswap
3. Export Your Private Key
{% hint style="warning" %} Security Warning: Never share your private key. Only use it in secure environments. {% endhint %}
MetaMask:
- Click the three dots menu
- Go to Account Details
- Click "Show Private Key"
- Enter your password
- Copy the key
Coinbase Wallet:
- Go to Settings
- Select your wallet
- Choose "Show Private Key"
- Authenticate and copy
4. Configure the SDK
Set your private key as an environment variable:
export BLOCKRUN_WALLET_KEY=0x...
Or pass it directly to the client:
{% tabs %} {% tab title="Python" %}
from blockrun_llm import LLMClient
# From environment (recommended)
client = LLMClient()
# Or pass directly
client = LLMClient(private_key="0x...")
{% endtab %}
{% tab title="TypeScript" %}
import { LLMClient } from '@blockrun/llm';
const client = new LLMClient({
privateKey: '0x...'
});
{% endtab %} {% endtabs %}
Security Best Practices
- Use Environment Variables - Never hardcode private keys
- Use a Dedicated Wallet - Create a separate wallet for API payments
- Limit Funds - Only keep enough USDC for expected usage
- Monitor Usage - Check your wallet transactions regularly
Checking Your Wallet
{% tabs %} {% tab title="Python" %}
from blockrun_llm import LLMClient
client = LLMClient()
print(f"Using wallet: {client.get_wallet_address()}")
{% endtab %}
{% tab title="TypeScript" %}
import { LLMClient } from '@blockrun/llm';
const client = new LLMClient({ privateKey: '0x...' });
console.log(`Using wallet: ${client.getWalletAddress()}`);
{% endtab %} {% endtabs %}