Using the API

Connect Cursor

Cursor calls your base URL from its own cloud, so the local Gatekeeper address does not work. What that costs, and the two ways to give Cursor a Gatekeeper it can reach.

How-toFor developers

Cursor takes a custom OpenAI base URL, so on paper it belongs on IDEs and agents with VS Code and OpenCode. It does not, because of one architectural difference that changes what you can promise yourself about your prompts. Read the first section before you decide to set this up.

Cursor calls the base URL from its own cloud

The base URL you type into Cursor is not an address Cursor dials. It travels to Cursor's backend as part of the request, and Cursor's backend makes the call to it. In the shipped client the override is stored as openAIBaseUrl, copied into the protobuf field aiserver.v1.ModelDetails.openai_api_base_url beside your API key, and sent to Cursor's own backend with every chat and agent request.

Three things follow, and none of them are configurable:

  • http://127.0.0.1:8787/v1 cannot work. The loopback address Cursor's backend resolves is its own, not yours. The ordinary Gatekeeper path from Connect a client is unavailable here.
  • Your prompts and your API key pass through Cursor's servers in clear. Cursor terminates the TLS, holds the key, and opens a second connection to wherever you pointed it. That is more than the direct path gives away. There, nobody between you and the router can read the traffic; you only lose the local proof.
  • Tab never uses your endpoint. Cursor's completion request carries no model credentials at all, and Cursor says so itself when you switch the key on: "Several of Cursor's features require custom models (Tab, Apply from Chat, Agent), which cannot be billed to an API key." Tab, and anything else in that list, keeps running on Cursor's own models.

A tunnel can restore the verification. Nothing can restore the confidentiality, which is Cursor's architecture and not a setting.

What this means for you

Where the call comes fromLocal verificationWho reads your prompt and your API key in plaintext
VS Code, OpenCode, curl, an SDKyour machine, through Gatekeeperyesnobody but you and the enclave
Cursor, pointed straight at the routerCursor's cloudnoyou, Cursor, the enclave
Cursor, pointed at a tunnelled GatekeeperCursor's cloudyesyou, Cursor, Cloudflare, the enclave
Cursor, pointed at your own Gatekeeper serverCursor's cloudyes, on that serveryou, Cursor, the enclave

Read the last two rows together. A tunnel puts the verification gate back and adds Cloudflare to the list of parties that see your text; it removes nobody. Your own server gets the same gate without Cloudflare, and moves the verdict off the machine you type on.

Everything about metering and billing is the same in every row. The console's Logs shows one metered row per generation, and never the prompt.

Give Cursor a public address for your Gatekeeper

Gatekeeper stays on your machine, bound to loopback as always; a tunnel client running beside it dials out and gets a public hostname that forwards in. Cursor's backend reaches the hostname, Gatekeeper still refuses anything whose evidence does not verify, and the verdict is still computed on your machine.

Two parties read your prompt and your API key in plaintext on this path, and these steps remove neither. Cursor's backend reads both, because that is how the client works. Cloudflare reads both as well: the quick tunnel's TLS ends at Cloudflare's edge, which decrypts your request, forwards it down the tunnel, and sends your Authorization header along with it. The tunnel buys back the verification gate. It is the second reader, not a fix for the first.

You need cloudflared, and a Gatekeeper that is already running and verifying: Install, Connect, Verify.

  1. Publish the endpoint. With Gatekeeper listening on 127.0.0.1:8787:

    shfrom the console
    cloudflared tunnel --url http://127.0.0.1:8787

    It prints a https://<words>.trycloudflare.com hostname. Leave it running; the hostname lives as long as the process and is different next time.

    The tunnel client connects to Gatekeeper over loopback, so do not rebind Gatekeeper to 0.0.0.0. That would make it reachable on your network for no gain.

  2. Treat the hostname as a credential. Anyone who learns it can send requests through your Gatekeeper. They cannot spend your credits: Gatekeeper forwards the caller's Authorization header unchanged and authenticates nobody, so a request without your key reaches the router and is refused with 401. But it is still your relay, and it is one more place your hostname is written down: Cursor's backend holds it like everything else in the request. Do not paste it anywhere public, and stop the tunnel when you stop working.

  3. Point Cursor at it. Cursor settings → Models → expand API Keys → OpenAI API Key:

    • API Key: your sk-tee-v1- key. Type it here and nowhere else: Cursor keeps it in its own secret storage, and there is no config file to put it in.
    • Override OpenAI Base URL: on.
    • Base URL: https://<words>.trycloudflare.com/v1.
    • Use OpenAI API Key: on. Cursor asks you to confirm; the warning it shows is the Tab limitation above.

    If there is no API Keys section at all, your Cursor team's administrator has disabled bring-your-own-key, and none of this is available to you.

  4. Add the model. In the same Models section, Add Custom Model → qwen3-coder-next, or whichever id the console's Models screen lists. Cursor rejects a name that looks like a URL or a secret; it wants the bare model id.

  5. Pick it in the chat model picker and send a message. Confirm it worked where the facts are: the Gatekeeper dashboard counts a request on the endpoint, and the console's Logs gains a metered row. The answer streams as it would locally; a quick tunnel forwards text/event-stream chunk by chunk rather than buffering it to the end.

A key saved in Cursor's settings is not a key Cursor has tested; nothing is sent anywhere when you type it in. The first real request is the first test.

Or run Gatekeeper on a server you own

If you already have a host with a certificate, run Gatekeeper there instead of tunnelling out of your laptop, and give Cursor its hostname directly. Same verification gate, and Cloudflare is not in the path: your prompt and your key are read in plaintext by Cursor's backend and by nobody else on the way. That is the floor for this client, and no configuration goes below it.

Run Gatekeeper headless or in a container is the setup: gatekeeper run --headless, a reverse proxy in front for TLS, and the same warning as step 2 about who can reach it. The verdict is then computed on that server rather than on your machine, which is the thing to be clear-eyed about: you are trusting a host you administer instead of the machine you are typing on.

Which to choose

For the full property, use VS Code or OpenCode: the call leaves your own machine, the verdict is computed there, and nobody sits in between. They are on IDEs and agents and they need no tunnel.

The paths on this page are for people who have chosen Cursor and want the verification gate anyway. They are worth having. They are not the same guarantee, and no amount of configuration makes them one.