Skip to content

Using HJToken in Cursor

Cursor is different from most tools: it decides which provider a request goes to based on the model name. So beyond the base URL and API key, you must also get the model name right — otherwise Cursor blocks the request locally and never sends it to us.

Follow the steps below in order.

Step 1: Create an API Key

Go to the API Keys pageCreate → copy the key (it looks like sk-...).

Step 2: Open Cursor's model settings

Cursor → Settings (⌘ , / Ctrl ,) → Models in the sidebar → expand the API Keys section.

Step 3: Paste the key into OpenAI API Key

Paste your HJToken key into the OpenAI API Key field and turn on the toggle next to it.

Put the key in the OpenAI field, not the Anthropic one — even if you intend to use Claude models. Step 5 explains why.

Step 4: Enable Override OpenAI Base URL

Turn on Override OpenAI Base URL and enter:

https://api.hjtoken.cn/v1

The trailing /v1 is required

Cursor appends /chat/completions directly to whatever you enter. Without /v1, the request hits a web page instead of the API, and you'll get an error that has nothing to do with the actual cause.

Step 5: Turn off the Anthropic API Key

If the Anthropic API Key field is enabled, turn it off (click Turn Off Anthropic Key).

Why: that field takes over every model whose name starts with claude-, and it offers no base URL override — Cursor would send your HJToken key to Anthropic's official endpoint, which of course doesn't recognize it.

Step 6: Add the model (the critical step)

In the model list on the Models page:

  1. Uncheck Cursor's built-in models (gpt-4o, claude-*, and so on);
  2. Click + Add model and type the model name manually.

To use Claude, you must use the anthropic/ prefixed name:

anthropic/claude-opus-5

Why Claude needs the prefix

Cursor gates a native name like claude-opus-5 twice: it hands it to the Anthropic Key field above (which can't point at a custom URL), and it's also one of Cursor's own hosted models, so it returns This model does not support custom API keys outright.

anthropic/claude-opus-5 neither starts with claude- nor matches a built-in name, so neither gate fires and the request reaches HJToken normally.

Both forms are equivalent on our side — same model, same billing. On the Models & Pricing page, click the copy icon next to a model name to grab whichever form you need.

GPT models aren't affected by this and work with their plain names (the prefix is optional):

gpt-5.4

Common model names

ModelEnter in Cursor
Claude Opus 5anthropic/claude-opus-5
Claude Sonnet 5anthropic/claude-sonnet-5
Claude Opus 4.8anthropic/claude-opus-4-8
Claude Sonnet 4.6anthropic/claude-sonnet-4-6
GPT-5.4gpt-5.4 or openai/gpt-5.4
GPT-5.5gpt-5.5 or openai/gpt-5.5

See Models & Pricing for the full list.

Step 7: Verify and use

  1. Click Verify — success means you're connected;
  2. Back in the chat box, select the model you just added (e.g. anthropic/claude-opus-5) in the model picker at the bottom — not Cursor's built-in Claude Opus 5;
  3. Start chatting.

Troubleshooting

ErrorCauseFix
This model does not support custom API keysYou selected one of Cursor's built-in hosted models (e.g. Claude Opus 5)Switch to the anthropic/claude-opus-5 entry you added manually
Access to private networks is forbiddenBase URL points at localhost / 127.0.0.1 / a private addressCursor sends requests from its own servers and can't reach your machine — use the public URL https://api.hjtoken.cn/v1
A chunk of HTML comes back, or JSON fails to parseThe base URL is missing the trailing /v1Change it to https://api.hjtoken.cn/v1
Model "xxx" is not in any account's model mapping in this groupWrong model name, or your plan doesn't include itCheck the available names on Models & Pricing
401 / authentication failureWrong key, or it was pasted into the Anthropic fieldMake sure the key is in OpenAI API Key and the Anthropic field is off

Known limitations

  • Agent / Composer mode may not work. Cursor has a known issue where enabling a custom API key (BYOK) causes Agent and Composer requests to be blocked on their side with This model does not support custom API keys. This is a Cursor routing issue, unrelated to HJToken. Use regular Chat mode if you hit it.
  • Tab completion and codebase indexing still run on Cursor's own service — they don't go through HJToken and don't consume your HJToken balance.

If you need full agent capabilities, consider editor extensions with more complete OpenAI-compatible support (Cline, Roo Code, and similar). They're configured the same way: base URL + API key + model name.

Still stuck?

See the FAQ or Support.

AI API gateway powered by Claude / OpenAI / Gemini