# Cursor

Source: https://staging-docs.aiand.com/integrations/cursor/

[Cursor](https://cursor.com) supports overriding the OpenAI base URL with your own API key — commonly called BYOK (Bring Your Own Key). ai& exposes an OpenAI-compatible `/v1/chat/completions` endpoint, so any tool-calling model in our [catalog](/models/catalog/) can drive Cursor's Agent mode.

<Aside type="caution">
  While the override is on, **every** request — including Cursor-hosted models selected in the built-in picker — is routed to your endpoint. Cursor-hosted models will fail with "model not available" unless your endpoint happens to serve that ID. To use Cursor's models again, turn the override off.
</Aside>

## Prerequisites

- [Cursor](https://cursor.com) installed
- An [ai& API key](https://console.aiand.com/settings/api-keys) with access to a tool-calling model

## Setup

<Steps>

1. Open Cursor Settings (`Cmd+,` / `Ctrl+,`)

2. Go to **Models** → scroll to **OpenAI API Key**

3. Paste your ai& API key into the **OpenAI API Key** field

4. Enable **Override OpenAI Base URL** and set it to:
   ```
   https://api.aiand.com/v1
   ```
   The `/v1` suffix is required — Cursor appends `/chat/completions` to whatever you provide.

5. Click **+ Add Model** in the model list and enter a model ID from the [catalog](/models/catalog/) that supports tool calling, e.g.:
   ```
   zai-org/glm-5.2
   ```
   Toggle the model on, then click **Verify** — Cursor sends a test request to confirm the key and model work

</Steps>

<Aside type="tip">
  `zai-org/glm-5.2`, `moonshotai/kimi-k3`, and `deepseek-ai/deepseek-v4-pro` are strong tool-callers and work well for Agent mode. Any model with `tool_calling` capability in the [catalog](/models/catalog/) works.
</Aside>

## Using Agent mode

Once verified, switch to Agent mode (the robot icon in the sidebar, or `Cmd+.` / `Ctrl+.`). The agent can:

- Read and edit files in your workspace
- Run terminal commands
- Use multi-turn tool calls to complete tasks

## Verify the connection

From the shell, confirm your key authenticates and the model is available:

<Tabs syncKey="os">
<TabItem label="macOS / Linux">

```bash
curl -sS https://api.aiand.com/v1/models \
  -H "Authorization: Bearer $AIAND_API_KEY" \
  | grep -o 'zai-org/glm-5.2'
```

</TabItem>
<TabItem label="Windows (PowerShell)">

```powershell
(Invoke-RestMethod https://api.aiand.com/v1/models `
  -Headers @{ Authorization = "Bearer $env:AIAND_API_KEY" }).data.id `
  | Select-String "zai-org/glm-5.2"
```

</TabItem>
</Tabs>

A match means the key works and the model is on your org.

## Troubleshooting

- **"Invalid API key"** — check that you copied the full key from the ai& dashboard, and that it hasn't been revoked.
- **"Model not found"** — the model ID must match the [catalog](/models/catalog/) exactly, including the provider prefix (`zai-org/`, `moonshotai/`, etc.).
- **Agent mode doesn't use tools** — make sure the model you selected supports tool calling. Not all models in the catalog do.
- **Verify fails despite correct key/model** — Cursor sometimes sends the verification request with `model: "default"`. Workaround: disable all other models in the list first, then verify.
- **Requests blocked or 403** — if you're behind a corporate proxy or VPN, it may be interfering. Try on a direct connection first.

## Switching back to Cursor-hosted models

1. Go to Settings → Models
2. Disable **Override OpenAI Base URL** (or clear the field)
3. Cursor's hosted models (GPT-4o, Claude, etc.) become available again

Your BYOK key is stored locally by Cursor and is not sent anywhere except the overridden endpoint.
