ToolAIPilotTAP
Sub

Ad

How To Get A Cursor AI API Key And Use OpenAI Codex Inside It
developerGuideยท 4 min readยท 3,879

How To Get A Cursor AI API Key And Use OpenAI Codex Inside It

Cursor does not hand out its own API key the way people expect. Here is the real setup, bringing your own OpenAI or Anthropic key, plus how to actually run OpenAI Codex inside Cursor.

๐Ÿ”ง Tools mentioned in this article
Cursor Docs: Bring Your Own API Key

Cursor Docs: Bring Your Own API Key

Cursor's own official documentation for BYOK setup

cursor.com

Visit
OpenAI Platform

OpenAI Platform

Where you actually generate the OpenAI key you paste into Cursor

platform.openai.com

Visit
OpenAI Codex GitHub

OpenAI Codex GitHub

The official Codex repo, including IDE extension install instructions

github.com

Visit
Marcus Webb

Marcus Webb

July 17, 2026

#how to get cursor ai api key#cursor bring your own api key#can i use openai codex in cursor#cursor custom api key setup 2026#cursor byok openai anthropic

The Confusion I Kept Running Into

A lot of searches for Cursor AI API key assume Cursor issues its own key the way OpenAI or Anthropic does. It does not. What Cursor actually offers is a bring your own key setting, where you paste in a key from OpenAI, Anthropic, Google, Azure, or AWS Bedrock, and Cursor uses that instead of its built in subscription models.

The Real Answer

There is no separate Cursor API key to generate. You get a key from whichever model provider you want, OpenAI or Anthropic being the two most common, and add it inside Cursor's own settings. This works on the free Cursor plan too, you do not need Cursor Pro to use your own key.

What BYOK actually changes. Once you add your own key, billing shifts to that provider directly, at their standard per token rate, instead of counting against Cursor's own subscription usage. Cursor still processes your prompts through its own backend, it just forwards the request using your key instead of its default one.

Step By Step Setup

  • Open Cursor and press Cmd + , on macOS or Ctrl + , on Windows and Linux, or use Cmd/Ctrl + Shift + P and search Cursor: Open Cursor Settings
  • Click Models in the settings sidebar
  • Scroll to the API Keys section and pick your provider, OpenAI, Anthropic, Google, Azure, or Bedrock
  • Generate a key from that provider's own dashboard first if you do not have one yet
  • Paste the key into the matching field and click Verify

Problems People Run Into

  • OpenAI's o1, o1-mini, and o3-mini reasoning models are explicitly not supported through custom keys according to Cursor's own docs, standard chat models work fine
  • Some features like Tab Completion require Cursor's own specialized models and will not work purely on a custom key
  • A blank Base URL field is the most common cause of an unauthorized user api key error when routing through a proxy or alternate provider
  • Anthropic keys start with sk-ant-, double check you copied the full string with no trailing space, this is a common paste error

Cursor states plainly that your key is not permanently stored, but it is sent to Cursor's servers with every request since Cursor still builds and processes the prompt on its backend before forwarding it. If that matters for your compliance needs, read Cursor's own privacy documentation before connecting a key tied to sensitive projects.

Now, Can You Actually Use OpenAI Codex In Cursor

Yes, and this is separate from the BYOK settings above. OpenAI's own Codex documentation explicitly lists Cursor, alongside VS Code and Windsurf, as a supported code editor for the Codex IDE extension, since Cursor is built on the same VS Code extension architecture.

bash
# install the Codex CLI first, this also powers the IDE extension
npm install -g @openai/codex

# or with Homebrew
brew install codex

# then inside Cursor's Extensions panel, search for the official OpenAI Codex
# extension and install it, same as installing any VS Code extension

Once installed, Codex inside Cursor authenticates the same two ways it does everywhere else, sign in with a ChatGPT Plus, Pro, Business, or Enterprise account for included usage, or supply an API key for pay per token billing through your OpenAI Platform account instead.

bash
# authenticate Codex with an API key instead of a ChatGPT login
echo "$OPENAI_API_KEY" | codex login --with-api-key

How I Actually Set This Up

I run Claude models as my default in Cursor through my Anthropic key for most day to day coding, and keep the Codex extension installed separately for tasks where I specifically want to compare its output or hand off a long running background task to Codex Cloud. Having both available in the same editor turned out more useful than picking one permanently.

The Result

Setup for both took under ten minutes combined once I had both API keys ready. The BYOK settings unlocked models beyond what my Cursor plan included, and the Codex extension gave me OpenAI's own agent running natively inside the same window, no separate app needed.

Verdict. There is no dedicated Cursor API key to hunt for, and that is fine, BYOK with an OpenAI or Anthropic key covers most needs in under five minutes. OpenAI Codex genuinely runs inside Cursor too, through the official extension, not through the BYOK settings, so treat them as two separate setups solving two different needs.

Should You Bother

If you already pay for OpenAI or Anthropic API credits elsewhere, BYOK in Cursor is worth the five minute setup, it stops you paying twice for the same usage. If you specifically want OpenAI's Codex agent and its background cloud execution, install the dedicated extension rather than trying to get the same experience through the generic API key fields.

Ad