> ## 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.

# Cursor

> Use the LeanMCP AI Gateway with Cursor IDE

# Cursor Integration

[Cursor](https://cursor.sh) is an AI-powered code editor. You can route Cursor's AI requests through the LeanMCP AI Gateway to gain visibility into what code is being sent to AI providers.

## 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>
</Steps>

## Configuration

<Steps>
  <Step title="Open Cursor Settings">
    Press `Cmd + ,` (Mac) or `Ctrl + ,` (Windows/Linux) to open Settings

    Or go to **Cursor** > **Settings** > **Cursor Settings**
  </Step>

  <Step title="Navigate to Models">
    Click on **Models** in the left sidebar
  </Step>

  <Step title="Configure OpenAI-Compatible Endpoint">
    Find the **OpenAI API Key** section and configure:

    **API Key:**

    ```
    leanmcp_your_api_key_here
    ```

    **Override OpenAI Base URL:**

    ```
    https://aigateway.leanmcp.com/v1/openai
    ```

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

  <Step title="Save and Restart">
    Save your settings and restart Cursor for changes to take effect.
  </Step>
</Steps>

## Verifying the Setup

1. Open any file in Cursor
2. Use Cmd+K (or Ctrl+K) to open the AI prompt
3. Ask a simple question like "What does this file do?"
4. Check your [LeanMCP Dashboard](https://leanmcp.com) to see the request logged

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/leanmcp/images/ai-gateway-cursor-verify.png" alt="Verify Cursor setup" />
</Frame>

## What You Can See

Once configured, you'll be able to see in your LeanMCP dashboard:

* **Full context sent** - exactly what code Cursor includes in each request
* **Token usage** - how many tokens each request uses
* **Model used** - which AI model processed your request
* **Sensitive data** - any API keys, passwords, or PII detected in your code

## Supported Models

Through the LeanMCP AI Gateway, Cursor can access:

| Provider      | Models                 |
| ------------- | ---------------------- |
| **OpenAI**    | All Latest Text Models |
| **Anthropic** | All Latest Text Models |

<Note>
  Cursor primarily uses the OpenAI endpoint. For Anthropic models, you may need to configure a separate API endpoint.
</Note>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Requests not appearing in dashboard">
    * Verify your API key is correct
    * Check the base URL is exactly `https://aigateway.leanmcp.com/v1/openai`
    * Restart Cursor after changing settings
  </Accordion>

  <Accordion title="Authentication errors">
    * Ensure your API key has **SDK** permissions
    * Check that you have credits in your account
    * Verify the API key hasn't been deleted
  </Accordion>

  <Accordion title="Slow responses">
    * The gateway adds minimal latency (\~50ms)
    * If significantly slower, check your internet connection
    * Try a different model (GPT-5.2 is faster than GPT-5.2)
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="View Your Logs" icon="list" href="/ai-gateway/observability">
    See all your AI requests
  </Card>

  <Card title="Security Settings" icon="shield" href="/ai-gateway/security">
    Block sensitive data
  </Card>
</CardGroup>
