Inja LLM Gateway
Get started

Cursor with ChatGPT, Claude & SuperGrok

Point Cursor at the Inja LLM Gateway and use the same ChatGPT, Claude, and SuperGrok subscriptions as Claude Code.

Last updated: 2026-07-23

Use Cursor with the same local gateway and consumer subscriptions as Claude Code: ChatGPT (Codex OAuth), Claude (setup-token), SuperGrok (Grok CLI / device OAuth).

You keep Cursor’s own models (Claude Fable 5, Composer 2.5, Cursor Grok, …) and add gateway models next to them with prefixed names so nothing collides.

  Cursor built-in (Claude Fable 5, Composer, …)  ──► Cursor cloud (unchanged)

  Custom model e.g. claude/fable-5
       │  OpenAI key + Override Base URL

  llm-gateway (HTTPS localhost)
       ├── ChatGPT subscription
       ├── Claude subscription
       └── SuperGrok (xAI)
In the picker Who serves it
Claude Fable 5 (built-in label) Cursor product
claude/fable-5 (you Add Model) llm-gateway → your Claude sub
Composer 2.5 Cursor
grok/composer-2.5 llm-gateway → SuperGrok Build
chatgpt/terra llm-gateway → ChatGPT sub

Related: Any app · Claude Code · Claude app · Codex · OAuth · xAI


How Cursor connects

Cursor’s Settings → Models can:

  1. Keep Cursor / third-party built-ins enabled (Fable, Sonnet, Composer, …).
  2. Take an OpenAI API Key (gateway edge key, e.g. local-dev).
  3. Override OpenAI Base URL to the gateway (…/v1) — this applies to OpenAI-compatible custom models, not Cursor-native routing.
  4. Add Model with prefixed gateway aliases (claude/…, chatgpt/…, grok/…, inja/…).

Cursor does not use Claude Code’s ANTHROPIC_BASE_URL env for these custom models. Custom entries talk OpenAI-shaped HTTP to the override URL; the gateway routes by model id.


Prerequisites

  1. Gateway binary (release or build from source).
  2. Shell helpers installed and sourced:
# From a release binary:
llm-gateway helpers install      # or: llm-gateway load-helpers
eval "$(llm-gateway helpers source)"

# From a git checkout (same scripts):
# source examples/shell/claude-code-helpers.sh
# source examples/shell/cursor-helpers.sh
  1. At least one subscription logged in:
llm-gateway auth login chatgpt
llm-gateway auth login claude     # optional
llm-gateway auth import grok      # or auth login grok
llm-gateway auth status
  1. HTTPS gateway running (same as Claude Code):
export KEY=local-dev
cc-gateway-up
cursor-setup          # overview
cc-gateway-logs -f    # see http + usage lines when Cursor hits the gateway

Cursor stores custom models in its state.vscdb (userAddedModels + openAIBaseUrl). Helpers can merge gateway models for you:

# 1) Fully quit Cursor (Cmd+Q) — required so the DB is not overwritten on exit
cursor-apply          # sets openAIBaseUrl + merges claude/fable-5, chatgpt/…, …
cursor-status         # confirm
# 2) Reopen Cursor
# 3) Settings → Models → OpenAI API Key = local-dev  (once; OS-encrypted, not written by script)
Command Effect
cursor-apply Backup DB + applicationUser JSON; set useOpenAIKey + openAIBaseUrl; merge gateway model names into userAddedModels and modelOverrideEnabled
cursor-status Show current base URL and custom models
cursor-rollback Restore last applicationUser / DB backup
cursor-models Print names only (manual Add Model)

Limits: the OpenAI API key lives in Electron safeStorage (secret://cursorAuth/openAIKey) and cannot be written safely from the shell — paste it once in the GUI. Built-in Cursor models are never removed.

Backups: ~/.local/state/inja-gateway/cursor-backups/.


Cursor Settings (GUI)

Open Cursor Settings → Models.

1. OpenAI API Key

Enable OpenAI API Key and paste:

local-dev

(Use the same value as KEY / edge key. Not your OpenAI Platform sk- — the gateway holds subscription OAuth.)

2. Override OpenAI Base URL

Enable Override OpenAI Base URL and paste:

https://127.0.0.1:8787/v1
Correct Wrong
https://127.0.0.1:8787/v1 https://127.0.0.1:8787 (missing /v1)
https://localhost:8787/v1 http://… if the gateway is TLS-only

Cursor calls {base}/chat/completions and, in Agent mode, often {base}/responses.

Leave Cursor built-ins on. Then Add Model for each gateway name. Prefer prefixes so the picker stays unambiguous:

Custom model name (Add Model) Upstream via gateway (Jul 2026) vs Cursor built-in
claude/fable-5 / claude/fable Claude Fable 5 (your Claude sub) Claude Fable 5 stays Cursor’s
claude/sonnet-5 / claude/sonnet Claude Sonnet 5 Cursor’s Claude Sonnet 5 stays
claude/opus / claude/opus-4-8 Claude Opus 4.8 Cursor Opus stays
claude/haiku Claude Haiku 4.5 Cursor Haiku stays
chatgpt/terra / chatgpt/sol / chatgpt/luna GPT-5.6 via ChatGPT sub Cursor GPT entries stay
grok/4.5 SuperGrok Grok 4.5 Cursor Grok stays
grok/composer-2.5 SuperGrok grok-build-0.1 Composer 2.5 stays Cursor’s
inja/fable-5, inja/gpt, … Same targets, explicit gateway tag

Also available: full provider ids anthropic/claude-fable-5, chatgpt/gpt-5.6-terra, xai/grok-4.5.

cursor-models    # print the list
# or open examples/cursor/models-to-add.txt

Avoid bare names like fable / fable-5 next to Cursor’s Claude Fable 5 — use claude/fable-5 or inja/fable-5.

Click Verify if available, then pick either a Cursor built-in or a claude/… / chatgpt/… / grok/… / inja/… model in Chat or Agent.

Combos

Only add prefixes for subscriptions you authenticated:

Goal Custom models to add
GPT only chatgpt/terra chatgpt/sol chatgpt/luna
Grok only grok/4.5 grok/composer-2.5
GPT + Grok both families
+ Claude also claude/fable-5 claude/sonnet-5 claude/opus

You do not need Cursor’s separate Anthropic API key for Claude-through-gateway. Custom OpenAI model name → gateway → Anthropic.


TLS / certificates

cc-gateway-up serves HTTPS with certs from examples/scripts/gen-localhost-tls.sh.

# Best trust story for Electron/Cursor:
brew install mkcert
mkcert -install
./examples/scripts/gen-localhost-tls.sh
cc-gateway-down && cc-gateway-up

If Verify fails with a certificate error, fix local trust (mkcert) rather than disabling TLS.


Helper commands

llm-gateway helpers install && eval "$(llm-gateway helpers source)"
# or: source examples/shell/{claude-code,cursor}-helpers.sh

export KEY=local-dev
cc-gateway-up       # background HTTPS gateway
cc-gateway-logs -f  # http + usage lines
cursor-setup        # print Settings → Models (coexistence guide)
cursor-apply        # automate base URL + custom models (quit Cursor first)
cursor-status       # show what Cursor has stored
cursor-rollback     # restore previous Cursor applicationUser
cursor-models       # list prefixed names to Add Model
cursor-verify       # GET /v1/models (shows claude/fable-5, inja/…)
cursor-write-cheatsheet
cc-gateway-status
cc-gateway-down

Repo notes: examples/cursor/README.md · models-to-add.txt.


What works (and limits)

Surface Expected
Cursor built-in models Stay in the picker; still served by Cursor (not the gateway)
Custom prefixed models OpenAI Chat Completions / Responses → gateway → your subs
Cursor Agent on gateway models Often Responses API (POST /v1/responses) — supported for openai / openai_compat (ChatGPT, xAI)
Claude via gateway from Cursor Custom name e.g. claude/fable-5 → gateway → Anthropic
Image / multimodal BYOK Some Cursor versions ignore custom base URL for images — text/agent is the supported path
Writing keys via script Not supported by Cursor (secure storage / GUI only)

Same gateway process can serve Claude Code and Cursor at once.


Troubleshooting

Symptom Fix
Connection refused cc-gateway-up; check curl -sk https://127.0.0.1:8787/healthz
404 on models Base URL missing /v1, or model name not in gateway aliases
401 KEY / OpenAI API Key mismatch with edge auth; or subscription not logged in
Verify TLS error mkcert -install + regenerate certs
Agent fails, Chat works Agent may need /v1/responses; ensure ChatGPT/xAI providers are openai / openai_compat
Wrong model family Check alias targets in examples/configs/claude-code-subscriptions.yaml
Confused Cursor vs gateway Fable Use claude/fable-5 for gateway; leave Claude Fable 5 as Cursor’s
Prefixed model 404 Restart gateway after config pull; cursor-verify should list claude/fable-5
cursor-verify
cursor-models
./llm-gateway auth status
curl -sk https://127.0.0.1:8787/v1/models -H "Authorization: Bearer local-dev" | jq -r '.data[].id' | grep claude/

Architecture

  1. Cursor sends OpenAI dialect to https://127.0.0.1:8787/v1.
  2. Gateway resolves model → alias → provider/model.
  3. Auth uses subscription store (oauth.credentials: chatgpt|claude|grok).
  4. Claude Code can use the same process with Anthropic dialect on the same host.

Config: examples/configs/claude-code-subscriptions.yaml.


Type to search…

↑↓ navigate↵ selectEsc close