How It Works
- You create a spend key in the Lava dashboard (or via REST API).
- You paste the key into your AI tool as the API key, and point it at
https://api.lava.so. - Lava routes your requests to the right provider, tracks usage, and enforces the limits you set.
Key Types
| Key | Prefix | Purpose |
|---|---|---|
| Spend key | lava_sk_ | Goes into your AI tool to make model requests |
| Wallet API key | lava_wk_ | Used to manage spend keys from code or terminal |
Your spend key (
lava_sk_*) is shown once when you create it. Copy it immediately. If you lose it, you can rotate the key from the dashboard to generate a new one.Creating a Spend Key
From the Dashboard
- Open Dashboard > AI Spend.
- Click Create Spend Key.
- Fill in the details:
- Name for your own reference (e.g. “Claude Code”, “Production Agent”)
- API format: OpenAI (
/v1/chat/completions) or Anthropic (/v1/messages), depending on your tool - Model access: allow all models, or restrict to specific ones
- Spend limit (optional): set a cap per day, week, month, or total
- Click Create and copy the full
lava_sk_*key.
From the Command Line
If you prefer working in a terminal, you can manage spend keys through the REST API. First, grab your wallet API key from AI Spend > Advanced: CLI and API access.key (shown once), spend_key_id, and key_preview.
List keys:
Managing Keys
From the AI Spend dashboard you can:- Pause or resume a key without revoking it
- Edit the name, spend limit, or model restrictions
- Rotate the secret if you think it was exposed (your limits and usage history stay the same)
- Revoke a key permanently
- View usage per key, including current cycle spend, total spend, and last used timestamp
Tool Setup Guides
We have step-by-step guides for connecting Lava to 9 popular AI tools, including Cursor, Claude Code, Vercel AI SDK, Raycast, LangChain, and more.Tool Setup Guides
Connect your spend key to Cursor, Claude Code, Vercel AI SDK, Anthropic SDK, Raycast, OpenClaw, LangChain, Cline, and Codex CLI
Troubleshooting
”Invalid API key” or 401 errors
- Make sure you’re using the full
lava_sk_*key, not the preview ending in****. - Check that the key is active, not paused or revoked. You can see this on the AI Spend dashboard.
- If you lost the original key, rotate it from the dashboard to get a new one.
”Model not allowed” errors
- Your key may have model restrictions. Check the allowed models on the key card in the dashboard, and make sure the model you’re requesting matches one of them.
Spend limit reached
- If your key has a spend limit and you’ve hit it, requests will be rejected until the next cycle resets (or you raise the limit).
- You can edit the spend limit from the dashboard or REST API without revoking the key.
Wrong API format
- If you’re getting unexpected errors, double-check that the API format on your spend key matches what your tool expects. Claude Code and the Anthropic SDK need Anthropic format. Most other tools need OpenAI format.
Base URL issues
- Anthropic-format tools: use
https://api.lava.so(without/v1), because the Anthropic SDK appends/v1/messagesautomatically. - OpenAI-format tools: use
https://api.lava.so/v1, because the OpenAI SDK appends/chat/completions.
FAQ
Do I need to pass awallet_id?
No. When you authenticate with a wallet API key, Lava automatically uses that wallet. Most users only have one wallet.
Can I use both the dashboard and the REST API?
Yes. They manage the same underlying spend keys. Create a key in the dashboard, update it from the CLI, or vice versa.
What’s the difference between spend keys and forward tokens?
Spend keys (lava_sk_*) are for your own AI tools and agents. Forward tokens are for the gateway proxy flow where you’re billing your customers. They serve different purposes and work independently.