Bottom line: Cursor CLI cannot connect to CodeGateway. The official CLI authenticates only with a Cursor account (browser login or API key) and exposes no custom upstream setting.
Why
Cursor CLI's auth methods: browser login (recommended) or API key from the Cursor Dashboard (
CURSOR_API_KEY/--api-key).There is no base-URL / provider / custom-endpoint option in the official parameter and configuration references.
Common confusion: the Cursor editor (IDE) supports custom models with API Key + Base URL — that is an editor feature; the CLI has no equivalent.
Alternatives
If you want a terminal coding agent with CodeGateway models:
Codex CLI integration: OpenAI's official CLI, custom upstream supported.
Qwen Code integration: one config entry, many models.
opencode integration: open source, strongest provider customization.
See the Agent CLI overview for the full list.
If you still want Cursor's model capabilities (outside the CLI), you can set a custom model with your own API key inside the Cursor editor — that is outside this doc hub's scope.
Possible future changes
If Cursor opens custom model endpoints for the CLI, this page will be updated immediately.
FAQ
Q: What is the Cursor CLI command? The installed binary is agent (e.g. agent "add a function"). Install: curl https://cursor.com/install -fsS | bash.
Q: I set a custom Base URL in the Cursor editor — does the CLI inherit it? No. The CLI and editor have separate configuration.
Q: Cursor official models only? Yes. The CLI model list covers account-available models (agent models); it cannot point at third-party endpoints.