Lava AI Gateway uses a forward token system for authenticating API requests. A forward token is a base64-encoded JSON string that combines your merchant credentials with a specific customer connection and pricing configuration.
A forward token encodes four fields into a single credential:
Component
Purpose
Obtained From
Secret Key
Your Lava API key
Generated in merchant dashboard
Connection ID
Links to a customer
Returned from checkout completion
Meter Slug
Specifies pricing configuration
Meter configuration in dashboard
Provider Key (Optional)
Enable BYOK (Bring Your Own Key)
Your own provider credentials
Self token vs. customer token: The self forward token from Gateway > Secrets points to an auto-created connection and zero-fee meter that charge your own wallet — use it for development and internal usage. To charge customers, generate tokens with their connection_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 self 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.