# Cursor (/docs/code-cli/cursor)

Cursor's chat and agent can run on any OhMyGPT model. Enter your OhMyGPT key and one base URL in Cursor's settings, add the model IDs you want, and they appear in the model picker next to Cursor's own.

## Configure [#configure]

1. Open **Cursor Settings → Models** and expand **API Keys**.
2. Paste your OhMyGPT key into **OpenAI API Key** and turn the key on.
3. Turn on **Override OpenAI Base URL** and enter `https://api.ohmygpt.com/v1`.
4. In the model list on the same page, add a custom model and type an OhMyGPT model ID exactly as `GET /v1/models` lists it, for example `anthropic/claude-sonnet-5-5`.
5. Pick that model in the chat model selector.

| Setting | Value |
|---|---|
| OpenAI API Key | your OhMyGPT key |
| Override OpenAI Base URL | `https://api.ohmygpt.com/v1` |
| Model | an ID from [Choose a model](#choose-a-model) |

Cursor sends these requests from its own servers, so your key and prompts pass through Cursor on their way to OhMyGPT.

## What runs on OhMyGPT [#what-runs-on-ohmygpt]

- Chat and agent requests for the model IDs you added.
- Cursor's built-in OpenAI models, while the override is on. Turn the override off to use them on your Cursor plan.

Tab completion and Cursor's other built-in models keep running on Cursor's own service.

## Check the connection [#check-the-connection]

Cursor sends Chat Completions requests. Send one to the free test model `ohmygpt/mock`:

```bash
curl https://api.ohmygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $OHMYGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ohmygpt/mock", "messages": [{"role": "user", "content": "ping"}]}'
```

```json
{
  "id": "chatcmpl-ohmygpt-mock",
  "object": "chat.completion",
  "model": "mock",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a mock reply from OhMyGPT. Your integration works; switch to a real model when ready."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 15, "completion_tokens": 17, "total_tokens": 32 }
}
```

To check Cursor's side for free, add `ohmygpt/mock` as a custom model and send a chat message; the reply above appears in the chat. The mock is available once your account has been topped up.

## Choose a model [#choose-a-model]

Every chat model works with Cursor:

```bash
curl -s https://api.ohmygpt.com/v1/models \
  | jq -r '.data[] | select(.available and any(.protocols[]?; .id == "openai-completions")) | .id'
```

Use the full ID, including the creator prefix (`anthropic/`, `openai/`, `zhipu/` and so on). Prices for each are on the [Models](https://www.ohmygpt.com/models) page.

## Troubleshooting [#troubleshooting]

| Symptom | Cause | Fix |
|---|---|---|
| `404` on every request | The base URL is missing `/v1`, or ends in `/chat/completions` | Enter exactly `https://api.ohmygpt.com/v1` |
| `401` with `Invalid API key` | The key in **OpenAI API Key** is mistyped or was deleted | Copy a key from [API keys](https://www.ohmygpt.com/keys) |
| `404` saying the model does not exist | The custom model name is not an OhMyGPT ID | Copy the ID from `GET /v1/models` |
| Requests still go to OpenAI | **Override OpenAI Base URL** is off | Turn it on |
| `402` | The balance or the key's spending limit is used up | Top up at [Billing](https://www.ohmygpt.com/billing) |

Every response carries an `X-Request-ID` header, and [Usage](https://www.ohmygpt.com/usage) shows what each request cost.
