EN ▾
OpenAI-compatible API, a Claude Code alternativehttps://api.claudecodeapikey.com/v1
Get API key

HomeGuide

Claude Code API for Cursor: Custom Endpoint Setup

Looking for a claude code api for cursor setup that does not depend on one vendor? Cursor can talk to any OpenAI-compatible endpoint, and this walkthrough shows each setting you need.

Updated

Isometric illustration of a code editor plugged into an API server, showing a custom endpoint setup

What you are setting up

Cursor is an editor with built-in AI features. Among its model settings is a field that lets you replace the OpenAI base URL with your own, along with a place to enter your own key. That makes it possible to send chat requests to any service that follows the OpenAI chat-completions format. This service does, so Cursor can use it as the model behind chat and inline edits.

The values you will enter are fixed. Base URL: https://api.claudecodeapikey.com/v1. Model name: uncensored. Key: the one from your account, sent as a Bearer token. Nothing else needs configuring on the server side.

Be clear about what this is. The model behind the endpoint is an open-weight model from an independent provider. It is not a Claude model and not the official API of Anthropic or anyone else. If you came here expecting Claude itself inside Cursor, this is a different thing, and the closing sections explain how to judge whether it is good enough for your work.

Before you open Cursor

Get these ready first, so you do not stop halfway.

  1. Create an account with Google or with email and password.
  2. Open the API key page and create a key. The key guide shows where each button is.
  3. Claim the $0.50 trial credit if you want to test without paying. It is one click, needs no card and lasts 7 days.
  4. Run a quick check from a terminal to confirm that the key works before blaming the editor.
curl https://api.claudecodeapikey.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Say ready."}]}'

A JSON reply with a message means the key and URL are good. An HTTP 401 means the key is wrong or has a stray space. Fix that here, because Cursor's error messages are less specific than curl's.

Step-by-step configuration in Cursor

Menu names shift between Cursor versions, so treat the labels below as a guide and look for the closest match.

  1. Open Cursor's settings and go to the models section.
  2. Find the field for an OpenAI API key and paste your key from this service.
  3. Turn on the option to override the OpenAI base URL, and enter https://api.claudecodeapikey.com/v1. Include the /v1 at the end and leave off any trailing path such as /chat/completions.
  4. Use the option to add a custom model, and type uncensored exactly, in lowercase.
  5. Press the verify or save button next to the key field. Cursor sends a small test request.
  6. Open a chat panel, pick uncensored in the model dropdown, and send a short prompt.

If the verify step fails but the curl check passed, check that you typed the URL into the base URL field and not into the key field, and that your Cursor version has not reset the override after an update. The quickstart keeps the current steps for this editor.

One detail worth knowing: a single override applies to the OpenAI provider slot. If you also use real OpenAI models through that slot, they will now be routed to this endpoint too. Many people keep a separate Cursor profile or turn the override off when they want to switch back.

Test with a real coding prompt

A greeting proves little. Use a prompt that exercises context and instructions. Select a function in your project, open chat, and ask for something concrete, such as adding input validation and a unit test. Watch for three things.

  • Streaming. The answer should appear token by token. The endpoint streams over SSE, so a long wait followed by a block of text suggests a proxy or setting is buffering it.
  • Context use. Attach two or three files and ask a question that needs all of them. The window is 100,000 tokens, which holds a lot of source, but your editor decides how much it actually sends.
  • Instruction following. Ask for a diff-only reply or for strict output format and see whether the model holds to it. Open-weight models differ here, and you want to learn it on day one.

Keep a short list of five real tasks from your own repository, and rerun them whenever you change a setting such as temperature. Judging from your own code beats any general claim, including ours.

Fixing the common errors

401 or invalid key

The key is wrong, expired from your clipboard, or has whitespace around it. Paste it again. Make sure the Authorization scheme is Bearer, which Cursor does for you when you use the OpenAI key field.

404 or model not found

Nearly always a base URL problem. A missing /v1 or an extra /chat/completions breaks the path. The model name must also be uncensored, with no capitals or spaces.

429 with rate_limited or concurrency

You hit a limit. The trial key allows 2 concurrent requests and 60 per minute, and a full key allows 8 concurrent and 300 per minute. An editor can fire several requests at once, for example chat plus background edits, and streams hold their slot until they end. The error code tells you which limit: rate_limited is requests per minute, concurrency is too many at once. A temporary overload also returns 429 with Retry-After: 5, so waiting five seconds and retrying is correct.

The answer cuts off

The window is 100,000 tokens, prompt plus completion. A very large attachment leaves little room for the reply. Send fewer files, or start a fresh chat.

Features that do nothing

The API is text only, and offers no embeddings. If a Cursor feature needs an embedding model or image input, it will not work through this endpoint.

Settings worth tuning once it works

After the first successful chat, a few adjustments make daily use smoother.

Lower the temperature for editing tasks. If your editor exposes it, a value around 0.2 gives steadier code. For brainstorming, raise it. Next, keep an eye on how much context you attach. The window is generous, but every attached file is billed as input, so closing unrelated tabs and excluding build folders keeps cost down and answers more focused.

If you use the agent or multi-step modes, remember the tool-calling support: the endpoint accepts tools and tool_choice and streams tool_calls. Whether a given Cursor feature uses them depends on the version, so run one small agent task and read what happens before trusting it with a large change. Finally, glance at the X-Balance-USD header in a terminal test once in a while, so a low balance never surprises you in the middle of work.

Using the same key in scripts

One advantage of an OpenAI-compatible endpoint is that the key you set up in Cursor also works in code. Here is a Node example, handy for build scripts or commit-message tools.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.claudecodeapikey.com/v1",
  apiKey: process.env.API_KEY,
});

const out = await client.chat.completions.create({
  model: "uncensored",
  messages: [
    { role: "user", content: "Write a conventional commit message for: fixed null check in parser" },
  ],
});

console.log(out.choices[0].message.content);

Store the key in an environment variable, not in a file you commit. Each response includes an X-Balance-USD header, so a script can warn you when credit runs low.

Cost and when to stay put

Editor use is input-heavy because each request carries file context. At $0.15 per 1M input tokens and $0.50 per 1M output, a request with 15,000 input tokens and 1,000 output tokens costs 0.015 x $0.15 + 0.001 x $0.50 = $0.00225 + $0.0005 = $0.00275. A hundred of those is $0.275. The pricing page has top-up amounts, starting at $20, with bonuses from $50.

Keep your existing setup if you depend on a specific vendor's model for hard refactors, or if your workflow relies on features a plain chat endpoint cannot give you. Use this one when you want a low per-token price, a plain API, and fewer content refusals on lawful work. Many developers keep both configured and switch per task.

Questions and answers

What base URL do I enter in Cursor?

Enter https://api.claudecodeapikey.com/v1 including the /v1. Do not add /chat/completions at the end.

What model name should I add?

Add a custom model named uncensored, in lowercase. It is the only model ID the API serves.

Does this give me Claude models in Cursor?

No. The endpoint serves one open-weight model from an independent provider. It is not an official API of Anthropic or any other vendor.

Why do I get 429 errors in the editor?

Either you passed the per-minute limit or you have too many requests at once. A trial key allows 2 concurrent and 60 per minute, a full key 8 and 300.

Can I try it without paying?

Yes. New users can claim $0.50 of trial credit on the API key page. It needs no card and is valid for 7 days.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key