Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AICursor Gateway Manager

Shell Script Platform Cloud Only No Local Model License Maintained

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.

AICursor Gateway Manager - terminal menu screenshot
Interactive terminal menu of AICursor Gateway Manager


πŸ“– Overview

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.


🎁 What You Gain From Using This Tool

  • πŸ’° 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.

βš™οΈ What the Tool Actually Does (Step by Step)

  1. Checks and installs dependencies β€” detects your Linux distribution's package manager and installs curl, jq, and python3 automatically if they are missing.
  2. 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.
  3. Builds a local Python gateway server β€” generates a small HTTP server (gateway.py) that listens only on 127.0.0.1 and exposes OpenAI-compatible endpoints (/v1/chat/completions, /v1/models, /health).
  4. Registers it as a systemd user service β€” creates and enables a systemd --user unit so the gateway starts automatically, restarts on failure, and runs sandboxed (NoNewPrivileges, PrivateTmp).
  5. 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.
  6. 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.
  7. Enforces free-only mode when enabled β€” if your active profile is marked free_only, the gateway forcibly overrides the model field to openrouter/free before forwarding, so you can never be billed by mistake.
  8. 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.
  9. Backs up your setup on demand β€” one command copies your profiles, routes, secrets file, and Cursor's settings.json into a timestamped backup folder.
  10. Uninstalls cleanly when you're done β€” removes only the gateway's service, files, and folders β€” Cursor itself and your projects are never touched.

✨ Features

  • 🌐 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/journalctl integration
  • πŸ–₯️ Simple interactive menu β€” no need to memorize flags

πŸ› οΈ Functions at a Glance

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

πŸ“¦ Requirements

  • Any Linux distribution with systemd --user support (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, or emerge)
  • An OpenRouter API key or any OpenAI-compatible provider key

πŸš€ How to Use

1. Download and make executable

chmod +x aicursor-manager.sh

2. Run the interactive menu

./aicursor-manager.sh

3. Or install directly with one command

./aicursor-manager.sh install

This installs dependencies, prompts for your OpenRouter API key, starts the gateway, tests it, and shows you the Cursor configuration values.

4. Configure Cursor

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

5. Manage anytime via the menu or CLI

./aicursor-manager.sh status
./aicursor-manager.sh test
./aicursor-manager.sh off

🎯 Why Use This Tool

  • ⏱️ 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 --user service, survives reboots and restarts automatically on failure
  • 🧹 Clean removal β€” uninstall only removes the gateway, never your projects or Cursor itself

πŸ”’ Safety & Privacy

  • βœ… 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.env with chmod 600 permissions, readable only by your user
  • βœ… No telemetry β€” the script does not collect or transmit any usage data of its own
  • βœ… Sandboxed service β€” the systemd unit runs with NoNewPrivileges=true and PrivateTmp=true
  • βœ… Non-destructive uninstall β€” removing the gateway never touches Cursor or your projects, and requires explicit confirmation (REMOVE)

πŸ–₯️ Compatibility

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 β€” ⚠️ Install curl, jq, python3 manually, then run the script
macOS / Windows β€” ❌ Not supported (requires systemd --user)

πŸ“„ License

Released under the MIT License. Use, modify, and share freely.


Made with 🐧 for the Linux desktop community

About

πŸ’Έ Stop paying for Cursor's AI. Route it through free OpenRouter models or your own API key in 30 seconds β€” cloud-only, secure, and works on every Linux distro.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages