- MCP flow: your host already runs the Lava MCP server, and the agent should authenticate the current MCP session with
login - SDK flow: you are writing Node.js agent code and want to use a secret key created in the dashboard
Prerequisites
- Node.js 18+
- A terminal
MCP flow
Use this when the agent is running inside Claude Code, Claude Desktop, Cursor, or another MCP-capable host with the Lava MCP server configured.1. Install the MCP server
- Claude Code
- Codex
- Manual JSON
2. Authenticate the MCP session
Ask the agent to call:loginto authenticate via the Lava browser login flowpromptto send chat completions to any AI model (all models use OpenAI format)callto execute any API call through the gateway (non-LLM APIs or native provider format)searchto find available API providers by natural language queryget_provider_docsto fetch upstream API documentation for a provider
login loads your merchant credentials and auto-provisions a spend key for gateway access. No manual token generation needed.
Use the MCP flow if your goal is to operate Lava from an agent host. Do not import the SDK just to get credentials when the MCP is already available.
SDK flow
Use this when you are writing application or CLI code yourself and want to authenticate from Node.js.1. Install the SDK
2. Get a secret key from the dashboard
Secret keys live under Dashboard > Gateway > Secrets. Use your existing key (aks_live_...) if you have one.
New developer Secret Key creation is paused, and Secrets shows a
request-access notice in place of key management. Email
support@lava.so to get API access for your
account. Existing keys keep working.
3. Initialize the SDK
Store the key in your environment or a secrets manager, then initialize the client:Deprecated: Browser Login From the SDK
Lava.login() opens your browser, lets you log in, and returns your existing API credentials.
Creating an account does not bypass the issuance pause. If no Secret Key
exists, SDK login returns
FORBIDDEN.Lava.exchangeAuthCode() exchanges the one-time code directly. Auth codes expire after 60 seconds and can only be used once.
What’s Next?
Route Traffic
Route live traffic after choosing MCP or SDK flow
Bill Your Customers
Set up usage-based pricing and checkout
Manage AI Spend
Create scoped API keys with spend limits
SDK Reference
Full Node.js SDK documentation