A lightweight, local OpenAI-compatible gateway that lets Cursor talk to OpenRouter or any OpenAI-compatible API provider β cloud-only, with automatic model discovery, free-tier routing, and a simple terminal menu. No model is ever downloaded or executed on your machine. Works out of the box on any Linux distribution, with automatic detection of your package manager.
Interactive terminal menu of AICursor Gateway Manager
AICursor Gateway Manager runs a small local HTTP gateway (127.0.0.1) that sits between Cursor and any OpenAI-compatible API. Point Cursor's "Override OpenAI Base URL" setting at the gateway, and it transparently forwards your requests to OpenRouter (or a custom provider), including a dedicated free-only mode.
It does not bypass Cursor's licensing or unlock any Cursor-only feature β it only routes requests through APIs that Cursor already allows you to configure.
- π° Lower or zero AI cost inside Cursor β by routing through OpenRouter's free-only mode, you can use Cursor's AI features without paying for API usage, and without accidentally switching to a paid model.
- π Freedom from a single provider β you are not locked into one paid API. You can plug in OpenRouter today and switch to any other OpenAI-compatible provider tomorrow, without reconfiguring Cursor each time.
- β±οΈ No manual setup work β normally, building a local API gateway means writing a Python server, a systemd service, and managing secrets by hand. This tool does all of that for you in seconds.
- π§ One place to manage everything β a single terminal menu controls every provider, key, route, and the gateway's ON/OFF state, instead of editing multiple config files by hand.
- π‘οΈ Reduced risk of leaking API keys β keys are stored locally with strict file permissions instead of being pasted directly into Cursor or scattered across config files.
- π Resilience β the gateway restarts itself automatically if it crashes, and survives system reboots, so your Cursor setup keeps working without you thinking about it.
- Checks and installs dependencies β detects your Linux distribution's package manager and installs
curl,jq, andpython3automatically if they are missing. - Creates a local configuration folder β sets up
~/.config/aicursor-gw/and~/.local/share/aicursor-gw/to store profiles, routes, secrets, and logs, all with restricted permissions (chmod 600/700) so only your user can read them. - Builds a local Python gateway server β generates a small HTTP server (
gateway.py) that listens only on127.0.0.1and exposes OpenAI-compatible endpoints (/v1/chat/completions,/v1/models,/health). - Registers it as a systemd user service β creates and enables a
systemd --userunit so the gateway starts automatically, restarts on failure, and runs sandboxed (NoNewPrivileges,PrivateTmp). - Stores your provider credentials safely β when you add OpenRouter or a custom provider, your API key is saved in an environment file with
chmod 600, never printed back to the screen after entry. - Routes every request Cursor sends β when Cursor sends a chat/completion request to
http://127.0.0.1:8765/v1, the gateway rewrites the model name according to your active profile/aliases and forwards it to the real provider (OpenRouter or your custom API), then returns the response back to Cursor unchanged. - Enforces free-only mode when enabled β if your active profile is marked
free_only, the gateway forcibly overrides the model field toopenrouter/freebefore forwarding, so you can never be billed by mistake. - Lets you test and monitor everything β a built-in test command checks both the local gateway and the live upstream API in one step, and logs are available instantly via the menu or
journalctl. - Backs up your setup on demand β one command copies your profiles, routes, secrets file, and Cursor's
settings.jsoninto a timestamped backup folder. - Uninstalls cleanly when you're done β removes only the gateway's service, files, and folders β Cursor itself and your projects are never touched.
- π OpenAI-compatible gateway β works with OpenRouter and any OpenAI-compatible endpoint
- π Free-only OpenRouter mode β automatically forces free models, avoiding accidental paid usage
- π Multiple provider profiles β switch between OpenRouter and custom providers
- π·οΈ Model aliases β map friendly names (
free,auto) to real model IDs - π Automatic model discovery β detects which models are free on your account
- π Automatic failover-ready routing via a simple
routes.json - π’π΄ One-command ON / OFF control via
systemd --user - π§ͺ Built-in API test β verifies both the local gateway and the upstream provider
- βοΈ Cursor settings helper β prints the exact values to paste into Cursor
- ποΈ Backup β snapshots your profiles, routes, secrets, and Cursor settings
- π Logs & health checks β gateway log file +
systemctl/journalctlintegration - π₯οΈ Simple interactive menu β no need to memorize flags
| Command | What it does |
|---|---|
install |
Installs dependencies, sets up config, enables the gateway |
on / enable |
Starts the gateway service |
off / disable |
Stops the gateway service |
status |
Shows service state, endpoint, and active profile |
test |
Tests the local gateway and the upstream API |
repair |
Re-installs config/service and restarts cleanly |
settings |
Prints the exact Cursor configuration values |
backup |
Backs up profiles, routes, secrets, and Cursor settings |
uninstall |
Removes the gateway only (Cursor and projects are untouched) |
menu (default) |
Opens the interactive terminal menu |
- Any Linux distribution with
systemd --usersupport (Arch, Debian, Ubuntu, Fedora, RHEL, openSUSE, Alpine, Void, Gentoo, and derivatives) bash,curl,jq,python3(auto-detected and installed via your distro's package manager βpacman,apt,dnf,yum,zypper,apk,xbps, oremerge)- An OpenRouter API key or any OpenAI-compatible provider key
chmod +x aicursor-manager.sh./aicursor-manager.sh./aicursor-manager.sh installThis installs dependencies, prompts for your OpenRouter API key, starts the gateway, tests it, and shows you the Cursor configuration values.
Open Cursor β Settings β Models and set:
OpenAI API Key : ON (use your provider key)
Override OpenAI Base URL : ON
Base URL : http://127.0.0.1:8765/v1
./aicursor-manager.sh status
./aicursor-manager.sh test
./aicursor-manager.sh off- β±οΈ Saves time β no manual gateway scripting or systemd unit writing
- π§© Provider-agnostic β swap between OpenRouter and any custom OpenAI-compatible API without touching Cursor's config again
- πΈ Cost control β free-only mode prevents accidental spend on paid models
- π Persistent β runs as a
systemd --userservice, survives reboots and restarts automatically on failure - π§Ή Clean removal β uninstall only removes the gateway, never your projects or Cursor itself
- β Cloud-only β no AI model is ever downloaded or executed locally; all inference happens on the provider's servers
- β
Local-only listener β the gateway binds strictly to
127.0.0.1, never exposed to your network - β
Secrets protected β API keys are stored in
~/.config/aicursor-gw/providers.envwithchmod 600permissions, readable only by your user - β No telemetry β the script does not collect or transmit any usage data of its own
- β
Sandboxed service β the
systemdunit runs withNoNewPrivileges=trueandPrivateTmp=true - β
Non-destructive uninstall β removing the gateway never touches Cursor or your projects, and requires explicit confirmation (
REMOVE)
The installer auto-detects your package manager and installs dependencies with the correct commands for your distro:
| Distro Family | Package Manager | Status |
|---|---|---|
| Arch Linux, CachyOS, Manjaro, EndeavourOS | pacman |
β Fully supported |
| Debian, Ubuntu, Linux Mint, Pop!_OS | apt / apt-get |
β Fully supported |
| Fedora, RHEL, CentOS Stream | dnf / yum |
β Fully supported |
| openSUSE (Leap / Tumbleweed) | zypper |
β Fully supported |
| Alpine Linux | apk |
β Fully supported |
| Void Linux | xbps |
β Fully supported |
| Gentoo | emerge |
β Fully supported |
| Any other distro | β | curl, jq, python3 manually, then run the script |
| macOS / Windows | β | β Not supported (requires systemd --user) |
Released under the MIT License. Use, modify, and share freely.
Made with π§ for the Linux desktop community