Lava AI Gateway uses a forward token system for authenticating API requests. A forward token is a base64-encoded JSON string that contains your secret key and, optionally, a customer ID and pricing configuration.
A forward token encodes up to four fields into a single credential:
Component
Purpose
Obtained From
Secret Key
Your Lava API key
Generated in merchant dashboard
Customer ID (Optional)
Links to a customer
Returned from checkout completion
Meter Slug (Optional)
Specifies pricing configuration
Meter configuration in dashboard
Provider Key (Optional)
Enable unmanaged (bring your own key)
Your own provider credentials; Lava still meters usage
Only secret_key is required. When you omit customer_id and meter_slug, costs are charged directly to your merchant wallet — this is the simplest way to get started. To charge customers, generate tokens with their customer_id and your pricing meter_slug.
Provider-specific headers (like anthropic-version) are passed through unchanged. The request body uses the provider’s native format — Lava doesn’t modify it.
Add "stream": true to your request body. Lava proxies SSE chunks in real-time without buffering — the response is identical to calling the provider directly. Usage and billing are recorded after the stream completes.
Verify your secret key matches the dashboard, ensure the Bearer prefix is in the Authorization header, and try the forward token from Gateway > Secrets to isolate the issue.
Copy
Ask AI
# Decode a forward token to inspect its contentsecho "your_forward_token" | base64 -d
CORS errors in browser
Lava blocks frontend requests to prevent token exposure. Always call Lava from your backend: Frontend → Your Backend → Lava → AI Provider.