Cursor
Configure Cursor to route model requests through TokenHub.
Cursor can route model requests through TokenHub's OpenAI compatible API gateway. Keep the official installation flow, then replace only the API key, Base URL, and model ID.
Use https://us-api.tokenhub.com/v1 as the OpenAI Base URL override. Depending on the Cursor version and selected model, Cursor may use Chat Completions or Responses-style requests, so do not assume a single endpoint path.
When to use it
Start in a small repository or test project. First ask the tool to read files, explain code, or produce a plan; only then enable edits, terminal commands, or agent automation.
Install or open the tool
Follow the official Cursor documentation to install or open the tool. If menus or command names differ, prefer the current official documentation.
For CLI tools, confirm the executable works before adding TokenHub credentials:
# open the tool, then open its model or provider settingsPrepare TokenHub credentials
Create a TokenHub API key and choose a model from the TokenHub model list that fits this tool.
export TOKENHUB_API_KEY="sk-..."Keep the key in your local shell, IDE secret storage, or the secure API key field of the tool. Do not commit it to the repository.
Configure TokenHub persistently
Use the tool configuration file or settings page first. This avoids the common problem where a terminal sees the environment variable but the IDE, plugin, or new window does not.
Provider values
Cursor officially supports BYOK for specific providers and standard chat models. A custom OpenAI-compatible endpoint is currently a limited Base URL override, not a first-class custom provider.
| Field | Value |
|---|---|
| Settings | Cursor Settings → Models → API Keys |
| API key field | OpenAI API Key |
| Base URL option | Override OpenAI Base URL |
| Base URL | https://us-api.tokenhub.com/v1 |
| Model | A TokenHub model compatible with the request format Cursor sends |
Settings file locations
| Field | Value |
|---|---|
| macOS | ~/Library/Application Support/Cursor/User/settings.json |
| Windows | %APPDATA%\Cursor\User\settings.json |
| Linux | ~/.config/Cursor/User/settings.json |
Use the settings UI first when the extension owns the schema. It stores the same values in a user-level settings file and avoids guessing private keys that may change between releases.
Custom keys apply only to standard chat models. Tab Completion and Cursor-owned models continue through Cursor. Some current Cursor versions can also send a Responses-shaped body to a Chat Completions path through the override, so verify a read-only chat before relying on Agent mode. If the Base URL override is absent or the request format is rejected, that Cursor version cannot connect to TokenHub reliably.
Do not map Chat, Agent, Composer, Apply, Fast, or Tab as if they were equivalent custom-provider slots. Start with one standard chat model and treat every other feature as unsupported until its requests appear successfully in TokenHub logs.
Temporary environment variables for debugging
Use the settings UI first when the extension owns the schema. It stores the same values in a user-level settings file and avoids guessing private keys that may change between releases.
Use temporary variables only to confirm the key, network, and model name. After validation, move the same values into the persistent configuration above.
Verify the connection
Test with a read-only prompt first, confirming that the model can read context without changing files. Then test edits, Apply, or agent tasks.
Read the project README and summarize it in three sentences. Do not modify any files.After a successful prompt, check TokenHub request logs for model name, endpoint, token usage, and billing group.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 or authentication failure | Confirm TOKENHUB_API_KEY is valid and saved in the same terminal, IDE, or client profile. |
| 404 or model not found | Use a model ID that exists in your TokenHub workspace and matches the selected protocol. |
| Wrong endpoint | Keep the Base URL exactly as shown. OpenAI-compatible tools usually need /v1; Claude-compatible tools usually do not. |
| Request timeout | Check network access to https://us-api.tokenhub.com, proxy settings, and workspace allowlists. |
| Tool uses another model | Recheck every chat, edit, apply, fast, and autocomplete model slot. |
Last updated on