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

# Raycast

> Use the LeanMCP AI Gateway with Raycast AI via BYOK

# Raycast Integration

[Raycast](https://raycast.com) is a productivity tool for macOS with powerful AI features. Using Raycast's **Bring Your Own Key (BYOK)** feature, you can route AI requests through the LeanMCP AI Gateway.

<Info>
  Raycast BYOK lets you use your own API keys from AI providers. By pointing to the LeanMCP AI Gateway, you get full visibility into your AI usage.
</Info>

## Prerequisites

<Steps>
  <Step title="Get Credits">
    Purchase credits at [leanmcp.com](https://leanmcp.com)
  </Step>

  <Step title="Create API Key">
    Create an API key at [leanmcp.com/api-keys](https://leanmcp.com/api-keys) with **SDK** permissions
  </Step>

  <Step title="Install Raycast">
    Download and install [Raycast](https://raycast.com) if you haven't already
  </Step>
</Steps>

## Understanding Raycast BYOK

Raycast's Bring Your Own Key feature allows you to:

* Use AI models without a Raycast Pro subscription
* Pay only for what you use via your own API keys
* Use Raycast AI with any OpenAI-compatible endpoint

<Note>
  With BYOK, you can send as many AI messages as you want at your own cost, without needing a Pro subscription.
</Note>

## Configuration

<Steps>
  <Step title="Open Raycast AI Settings">
    1. Open Raycast (default: `Cmd + Space`)
    2. Type "Raycast Settings" and press Enter
    3. Navigate to the **AI** section

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/leanmcp/images/ai-gateway-raycast-settings.png" alt="Raycast AI Settings" />
    </Frame>
  </Step>

  <Step title="Find Custom API Keys Section">
    Scroll down to find the **Custom API Keys** section.
  </Step>

  <Step title="Add OpenAI-Compatible Key">
    For OpenAI models via LeanMCP:

    **Provider:** OpenAI (or OpenRouter for all providers)

    **API Key:**

    ```
    leanmcp_your_api_key_here
    ```

    <Warning>
      Raycast's standard BYOK doesn't support custom base URLs directly. See the OpenRouter method below for full gateway support.
    </Warning>
  </Step>

  <Step title="Validate the Key">
    Click **Validate** to test the API key connection.
  </Step>
</Steps>

## Using OpenRouter for Full Gateway Support

For complete LeanMCP AI Gateway integration with Raycast, use OpenRouter as the provider:

<Steps>
  <Step title="Select OpenRouter">
    In Raycast AI Settings, choose **OpenRouter** as the provider.
  </Step>

  <Step title="Enter LeanMCP API Key">
    Enter your LeanMCP API key in the OpenRouter API key field.

    <Note>
      The LeanMCP AI Gateway is OpenRouter-compatible, so Raycast will route requests through the gateway.
    </Note>
  </Step>

  <Step title="Select Models">
    Choose from available models. All requests will go through the LeanMCP gateway.
  </Step>
</Steps>

## What Raycast Sends to AI

When you use Raycast AI, the following may be sent:

* Your prompt/question
* Selected text (if using "Ask AI about selection")
* Clipboard contents (if using clipboard features)
* File contents (if using file-based commands)

With the AI Gateway, you can see exactly what's sent in each request.

## Model Selection

After configuring BYOK, you'll see a key icon next to models using your API key:

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/leanmcp/images/ai-gateway-raycast-models.png" alt="Raycast model picker with BYOK" />
</Frame>

Available models depend on your configuration:

* **OpenAI**: GPT-5.2, GPT-5.2, GPT-5.2
* **Anthropic**: Claude Sonnet 4.5, Claude Opus 4.5
* **OpenRouter**: Access to 100+ models

## Privacy Considerations

<Info>
  When using BYOK (excluding OpenRouter), Raycast processes requests through their servers to unify APIs and add features. With the LeanMCP gateway, you get an additional layer of logging and control.
</Info>

Learn more about Raycast's [AI Privacy + Security](https://manual.raycast.com/ai).

## Local Models Alternative

If you want complete privacy, Raycast also supports local models via Ollama:

1. Install [Ollama](https://ollama.com/download)
2. Pull a model: `ollama pull llama2`
3. Select the local model in Raycast

<Note>
  Local models run entirely on your machine and don't go through any external service.
</Note>

## Benefits of Using AI Gateway with Raycast

<CardGroup cols={2}>
  <Card title="Usage Tracking" icon="chart-line">
    See exactly how much you're using Raycast AI
  </Card>

  <Card title="Cost Monitoring" icon="dollar-sign">
    Track spending across all your Raycast AI usage
  </Card>

  <Card title="Sensitive Data Alerts" icon="shield">
    Get notified if clipboard or selection contains secrets
  </Card>

  <Card title="Request History" icon="clock-rotate-left">
    Review past AI interactions and their costs
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="API key validation fails">
    * Ensure your LeanMCP API key has credits
    * Check the key has SDK permissions
    * Verify you're using the correct provider setting
  </Accordion>

  <Accordion title="Models not appearing">
    * Restart Raycast after adding the API key
    * Check Raycast has the latest version
    * Try removing and re-adding the API key
  </Accordion>

  <Accordion title="Requests not in LeanMCP dashboard">
    * Confirm you're using the LeanMCP API key
    * Some requests may go directly to providers depending on Raycast's routing
    * Try using OpenRouter mode for guaranteed gateway routing
  </Accordion>
</AccordionGroup>

## Resources

* [Raycast AI Manual](https://manual.raycast.com/ai)
* [Raycast BYOK Documentation](https://manual.raycast.com/ai#bring-your-own-key-byok)

## Next Steps

<CardGroup cols={2}>
  <Card title="View Your Usage" icon="chart-bar" href="/ai-gateway/observability">
    Monitor Raycast AI requests
  </Card>

  <Card title="Optimize Costs" icon="piggy-bank" href="/ai-gateway/token-optimization">
    Reduce token usage
  </Card>
</CardGroup>
