# Cursor (/docs/integrations/cursor)

Use codai in Cursor Chat and Agent through the OpenAI key slot, and add the codai MCP server.

Cursor needs your codai key in the **OpenAI API Key** slot, the base URL `https://ai.codai.ro/v1` and a custom model named `codai`.

## Before you start [#before-you-start]

- A codai key from [hub.codai.ro](https://hub.codai.ro) → **Keys → Create key** (details in the [quickstart](../gateway/index.mdx)).
- A paid Cursor plan. Cursor does not allow your own key on the Free plan.
- On Teams or Enterprise, an admin may have to enable the OpenAI key switch.

## Chat and Agent [#chat-and-agent]

<Steps>
<Step>
Open **Cursor Settings → Models** and expand **API Keys** at the bottom.
</Step>
<Step>
Paste your `codai_…` key into **OpenAI API Key** and turn on **Use OpenAI API Key**.
</Step>
<Step>
Turn on **Override OpenAI Base URL** and enter `https://ai.codai.ro/v1`. Do not append `/chat/completions`.
</Step>
<Step>
Add a custom model named exactly `codai`. Restart Cursor, open a new chat and pick `codai`.
</Step>
</Steps>

Do not name the model `claude-…`: Cursor sends those names through its Anthropic key slot, not the OpenAI one.

<Callout type="info">
Cursor routes every request through its own servers to build the final prompt. Your key travels with each request through Cursor's backend, and the base URL must be public HTTPS — `localhost` and LAN addresses do not work.
</Callout>

## MCP [#mcp]

Global file: `~/.cursor/mcp.json` (Windows: `%USERPROFILE%\.cursor\mcp.json`). Project file: `.cursor/mcp.json`. Cursor merges both; the project file wins.

```json title="~/.cursor/mcp.json"
{
  "mcpServers": {
    "codai": {
      "url": "https://ai.codai.ro/mcp",
      "headers": { "Authorization": "Bearer ${env:CODAI_API_KEY}" }
    }
  }
}
```

- `${env:CODAI_API_KEY}` reads the OS environment. `envFile` does not apply to remote servers, so set the variable in your shell or system settings.
- Restart Cursor after editing the file.

## What works and what does not [#what-works-and-what-does-not]

| Feature | With codai |
| --- | --- |
| Chat | Works |
| Agent | Works |
| Tab completion | Does not — always uses Cursor's own models |
| Cloud Agents | Does not — they use a curated set of models |
| Anthropic base URL override | Not available in Cursor |

On Teams and Enterprise, Cursor still charges its own per-token rate on requests that use your key, and Zero Data Retention does not apply to them.

## Troubleshooting [#troubleshooting]

- **`404`** — the base URL has `/chat/completions` on it, or lacks `/v1`. It must be exactly `https://ai.codai.ro/v1`.
- **The key field does not take focus** — a known bug in Cursor 3.15.x, fixed in 3.15.20. Press Tab to reach the field.
- **`codai` does not appear** — restart Cursor and open a new chat; existing chats keep their model.
- **MCP sends an empty key** — `CODAI_API_KEY` is not set in the environment Cursor started from.

## Sources [#sources]

Checked 2026-10-02.

- [Cursor — API keys](https://cursor.com/docs/settings/api-keys)
- [Cursor — MCP](https://cursor.com/docs/context/mcp)
- [Cursor help — MCP](https://cursor.com/help/customization/mcp)
- [Cursor — Cloud Agents](https://cursor.com/docs/cloud-agent)
