> ## Documentation Index
> Fetch the complete documentation index at: https://lava.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool Setup Guides

> Connect Lava spend keys to Cursor, Claude Code, Raycast, Vercel AI SDK, and more

Step-by-step instructions for connecting Lava to popular AI tools. In every case, the pattern is the same: set the API key to your `lava_sk_*` key, and point the base URL to Lava.

<Tip>
  **Which API format?** Tools that use the OpenAI SDK or OpenAI-compatible APIs need the **OpenAI** format. Tools that use the Anthropic SDK (like Claude Code) need the **Anthropic** format. When in doubt, start with OpenAI.
</Tip>

## Vercel AI SDK

Use Lava as your OpenAI-compatible backend in any Vercel AI SDK app.

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and click **Create Spend Key**. Set the API format to **OpenAI (/v1/chat/completions)**, choose the model(s) you want, and copy the key.
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    npm install ai @ai-sdk/openai
    ```
  </Step>

  <Step title="Configure Lava in your app">
    Add your spend key as an environment variable:

    ```bash theme={null}
    export LAVA_SPEND_KEY="lava_sk_your_key_here"
    ```

    Then create an OpenAI client pointed at Lava:

    ```ts theme={null}
    import { streamText } from 'ai';
    import { createOpenAI } from '@ai-sdk/openai';

    const lava = createOpenAI({
      apiKey: process.env.LAVA_SPEND_KEY,
      baseURL: 'https://api.lava.so/v1',
    });

    const result = await streamText({
      model: lava('claude-opus-4-6'),
      messages: [{ role: 'user', content: 'Write a one-line release note.' }],
    });

    for await (const textPart of result.textStream) {
      process.stdout.write(textPart);
    }
    ```
  </Step>

  <Step title="Run and verify usage">
    Send a test prompt from your app. You'll see spend and usage on your **AI Spend** dashboard for that key.
  </Step>
</Steps>

***

## Claude Code

Route Claude Code requests through Lava using Anthropic-format spend keys.

<Steps>
  <Step title="Create a Spend Key in Anthropic format">
    Go to **Dashboard > AI Spend**, click **Create Spend Key**, and set the API format to **Anthropic (/v1/messages)**.
  </Step>

  <Step title="Point Claude Code to Lava">
    Set these environment variables before launching Claude Code:

    ```bash theme={null}
    export ANTHROPIC_AUTH_TOKEN="lava_sk_your_key_here"
    export ANTHROPIC_BASE_URL="https://api.lava.so"
    ```
  </Step>

  <Step title="Run Claude Code">
    Start Claude Code as normal. Requests now go through Lava's `/v1/messages` path and usage is tracked in **AI Spend**.
  </Step>
</Steps>

***

## Anthropic SDK

Use a Lava spend key with any Anthropic-style client or agent runtime.

<Steps>
  <Step title="Create a Spend Key for Anthropic format">
    Go to **Dashboard > AI Spend**, click **Create Spend Key**, and set the API format to **Anthropic (/v1/messages)**.
  </Step>

  <Step title="Set Anthropic environment variables">
    ```bash theme={null}
    export ANTHROPIC_API_KEY="lava_sk_your_key_here"
    export ANTHROPIC_BASE_URL="https://api.lava.so"
    ```

    <Note>
      Keep the base URL at `https://api.lava.so` (without `/v1`). Anthropic clients automatically append `/v1/messages`.
    </Note>
  </Step>

  <Step title="Use the Anthropic client as usual">
    ```ts theme={null}
    import Anthropic from '@anthropic-ai/sdk';

    const client = new Anthropic({
      apiKey: process.env.ANTHROPIC_API_KEY,
      baseURL: process.env.ANTHROPIC_BASE_URL,
    });

    const response = await client.messages.create({
      model: 'claude-opus-4-6',
      max_tokens: 512,
      messages: [{ role: 'user', content: 'Summarize this in one paragraph.' }],
    });

    console.log(response.content);
    ```

    Most Anthropic-based agent SDKs use the same `ANTHROPIC_API_KEY` and base URL settings, so once those are set, requests route through Lava automatically.
  </Step>
</Steps>

***

## Cursor

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Configure Cursor">
    In Cursor, go to **Settings > Models > OpenAI API Key**. Paste your `lava_sk_*` key and set the base URL to `https://api.lava.so/v1`.
  </Step>

  <Step title="Start coding">
    Select a model and start coding. Usage appears in your **AI Spend** dashboard.
  </Step>
</Steps>

***

## Raycast

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Configure Raycast">
    Open **Raycast > Settings > Extensions > AI**. Under provider settings, add a custom OpenAI-compatible provider:

    * **API Key:** your `lava_sk_*` key
    * **Base URL:** `https://api.lava.so/v1`
  </Step>

  <Step title="Start chatting">
    Pick a model and start chatting. Usage is tracked in **AI Spend**.
  </Step>
</Steps>

***

## OpenClaw

Use Lava as a custom OpenAI-compatible provider in OpenClaw.

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Add Lava to your agent's model config">
    In your agent's model config (e.g. `~/.openclaw/agents/<agentId>/agent/models.json`):

    ```json5 theme={null}
    {
      models: {
        mode: "merge",
        providers: {
          lava: {
            baseUrl: "https://api.lava.so/v1",
            apiKey: "lava_sk_your_key_here",
            api: "openai-completions",
            models: [
              { id: "claude-opus-4-6", name: "Claude Opus 4.6" },
              { id: "gpt-4o", name: "GPT-4o" }
            ]
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Select a Lava model">
    Choose one of the model IDs you configured. OpenClaw will route calls through Lava with spend controls and usage tracking.
  </Step>
</Steps>

***

## LangChain

Connect LangChain to Lava using ChatOpenAI custom base URL support.

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Install LangChain OpenAI package">
    ```bash theme={null}
    npm install @langchain/openai @langchain/core
    ```
  </Step>

  <Step title="Use ChatOpenAI with Lava base URL">
    ```ts theme={null}
    import { ChatOpenAI } from "@langchain/openai";

    const llm = new ChatOpenAI({
      model: "claude-opus-4-6",
      apiKey: process.env.LAVA_SPEND_KEY,
      configuration: {
        baseURL: "https://api.lava.so/v1",
      },
    });

    const response = await llm.invoke("Give me 3 bullet points about this repo.");
    console.log(response.content);
    ```
  </Step>

  <Step title="Verify in AI Spend">
    Run a request and confirm usage appears on your **AI Spend** dashboard.
  </Step>
</Steps>

***

## Cline

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Authenticate Cline against Lava">
    ```bash theme={null}
    cline auth -p openai -k lava_sk_your_key_here -b https://api.lava.so/v1 -m claude-opus-4-6
    ```
  </Step>

  <Step title="Run Cline normally">
    Start Cline and run a prompt. Calls route through Lava with your key limits and usage tracking.
  </Step>
</Steps>

***

## Codex CLI

Use Lava as a custom model provider in OpenAI Codex CLI.

<Steps>
  <Step title="Create a Spend Key">
    Go to **Dashboard > AI Spend** and create a key with **OpenAI (/v1/chat/completions)** format.
  </Step>

  <Step title="Set the environment variable">
    ```bash theme={null}
    export LAVA_SPEND_KEY="lava_sk_your_key_here"
    ```
  </Step>

  <Step title="Add Lava to Codex config">
    In `~/.codex/config.toml`:

    ```toml theme={null}
    model = "claude-opus-4-6"
    model_provider = "lava"

    [model_providers.lava]
    name = "Lava"
    base_url = "https://api.lava.so/v1"
    env_key = "LAVA_SPEND_KEY"
    wire_api = "chat"
    ```
  </Step>

  <Step title="Start Codex">
    Run `codex` as normal. Requests route through Lava, and usage appears in **AI Spend**.
  </Step>
</Steps>
