EN ▾
Claim trial key
Cursor OpenAI API Key(7)

Last updated

Cursor OpenAI API Key: Setup for a Custom Endpoint

The cursor openai api key field is a generic slot for any OpenAI-compatible service: it holds a key and, with a base URL override, sends it wherever you point it. This guide covers the setup, a safety check most guides skip, and a script that proves the connection works.

Summary

  • The OpenAI field is only a slot: the base URL decides who receives the key.
  • Never leave a real OpenAI key in the field when you change the base URL.
  • Run the test script first. If it passes, the editor settings are the only suspect.
  • This service is independent of OpenAI; the model name is uncensored.
A cable linking a socket to a control panel, with a matched plug glowing green

The safety check before you paste anything

In Cursor-style editors the field is labelled for OpenAI because the protocol it speaks comes from OpenAI. It has no way to know who really owns the key. Whatever you type goes to whatever base URL is configured. Two mistakes follow from that:

  • You keep a real OpenAI key in the field and set the base URL to a third party. Your OpenAI key is now sent to that third party.
  • You paste this service's key and leave the base URL at its default. The key goes to OpenAI, which rejects it, and the key has been shared with a service it does not belong to.

The rule is simple: change the key and the base URL in the same sitting, and make sure they come from the same provider. If you use a real OpenAI key elsewhere, keep it out of this field when a custom URL is active. This service does not resell OpenAI and has no connection with it; its key is useless anywhere else, which is the point.

What to enter

SettingValue
OpenAI API keyThe key from the API key page
Override OpenAI base URLhttps://api.cursoropenaiapikey.com/v1
Custom model nameuncensored

Menu names change between versions, so look for the field named for the OpenAI API key, then for an option that mentions the base URL. Keep /v1 at the end and nothing after it. The client adds /chat/completions itself.

New accounts can claim $0.50 of trial credit with one click on the key page after signing up with Google or email. It needs no card, lasts 7 days and is limited to one per person, which is enough to finish this guide.

Test the connection with a script

Do this before the editor. A script gives you clear errors, and it exercises the features editors rely on. Save it as check.py and set the key in your shell with export TEST_KEY=....

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cursoropenaiapikey.com/v1",
    api_key=os.environ["TEST_KEY"],
)

# 1. The model list should contain "uncensored"
print([m.id for m in client.models.list().data])

# 2. A plain chat call
r = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Reply with the word ok."}],
)
print("chat:", r.choices[0].message.content, r.usage.total_tokens, "tokens")

# 3. Streaming
parts = []
for chunk in client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Count from 1 to 5."}],
    stream=True,
):
    if chunk.choices and chunk.choices[0].delta.content:
        parts.append(chunk.choices[0].delta.content)
print("stream:", "".join(parts))

# 4. JSON mode
j = client.chat.completions.create(
    model="uncensored",
    response_format={"type": "json_object"},
    messages=[{"role": "user", "content": 'Return JSON with the key "status" set to "ok".'}],
)
print("json:", j.choices[0].message.content)

All four should print without an exception. Agent modes in editors depend on tool calling, so add a fifth check if you plan to use one:

# same client as above: base_url https://api.cursoropenaiapikey.com/v1
t = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "What time is it?"}],
    tools=[{"type": "function", "function": {
        "name": "get_time",
        "description": "Return the current time",
        "parameters": {"type": "object", "properties": {}},
    }}],
    tool_choice={"type": "function", "function": {"name": "get_time"}},
)
print("tool call:", t.choices[0].message.tool_calls)

You should see a get_time call. Results go back to the model as messages with role: "tool".

Enter the settings in the editor

  1. Open the editor settings and go to the models section.
  2. Remove any real OpenAI key from the field. Paste this service's key.
  3. Switch on the base URL override and paste the URL from the table above.
  4. Add the model uncensored and select it in the chat panel.
  5. Send a short test message and watch the balance: the X-Balance-USD header drops a little after each reply, and you can also query GET /v1/balance.

Some versions have a verify button that tests the key against the provider. If it fails while your script passes, look for a stray space, a doubled /v1 or a different model name than uncensored. Also check whether the feature you are using runs on your key at all. Editors can run some features on the vendor's own models, and the editor's documentation is the source of truth for your version.

If an agent mode misbehaves while plain chat works, the likely cause is a tool-calling detail in the editor version and not the key. Keep a log of one failing request, including the X-Request-Id response header, before you contact support. That one value lets the team find the exact call.

Using the same values in other OpenAI-compatible tools

The official OpenAI SDKs read two environment variables, so many tools pick up a custom endpoint without further settings. Use a shell session scoped to the project so that the values do not leak into unrelated work:

export OPENAI_BASE_URL="https://api.cursoropenaiapikey.com/v1"
export OPENAI_API_KEY="YOUR_KEY"
python -c "from openai import OpenAI; print(OpenAI().chat.completions.create(model='uncensored', messages=[{'role':'user','content':'ok?'}]).choices[0].message.content)"

If that prints a reply, any tool that respects those variables will work with the same pair. Unset them when you are done (unset OPENAI_BASE_URL OPENAI_API_KEY) so a later command does not send the wrong key to the wrong host. This is the same hazard as the one at the top of this page, in another form.

Errors and what they mean here

  • 401: wrong key, revoked key, or the key sits in the wrong field. Regenerate it on the key page; the old one stops working at once.
  • 404: the base URL is wrong. It should end in /v1.
  • Model not found: use the name uncensored.
  • 429 concurrency: trial keys allow 2 requests at once; full keys allow 8. A streamed request keeps its slot until the stream ends.
  • 429 rate_limited: 60 requests per minute on trial, 300 on a full key.
  • 429 with Retry-After: 5: temporary overload; try again in five seconds.
  • Context error: prompt plus completion went past 100,000 tokens. Trim what you send.

The docs list all parameters, including temperature, top_p, stop, seed and the penalties, which are passed through.

What it costs and what you should expect

You pay $0.15 per 1M input tokens and $0.50 per 1M output tokens from prepaid credit. A request with 10,000 input tokens and 800 output tokens costs $0.0015 plus $0.0004, which is $0.0019. The $0.50 trial covers more than 260 of those. Failed or refused requests are not charged.

Expect one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is text only. It does not do images, audio, embeddings or fine-tuning, and it is not a stand-in for any OpenAI model. Whether it suits your code tasks is something to test on your own files. Top-ups from $20 to $500 are crypto only, listed on the pricing page. The note on a production checklist for an LLM key covers storage and rotation habits in more depth.

Common questions

Is this an OpenAI key?

No. It is a key for an independent service that speaks the same protocol. It only works with this service's base URL and the model name uncensored.

Do I need to remove my own OpenAI key from the editor?

Yes, while a custom base URL is active. Otherwise the editor may send your real OpenAI key to the third-party host.

Which model name should I add in the editor?

Add a custom model called uncensored, in lowercase, and select it in the chat panel.

Does the trial need a card?

No. Claim $0.50 with one click on the API key page after sign-up. It is valid for 7 days and limited to one per person.

Get your API key now

Sign up, retrieve your key, update the base URL in Cursor. Done.

Start with free credits

Enter email and password, receive your key immediately.