How to use Cursor with paid OpenRouter models and free LiteLLM models
A step-by-step guide to install the Cursor editor on Mac, Windows or Linux and connect it to your own models: paid ones from OpenRouter and the free or local ones you serve with LiteLLM.
Cursor is a code editor with built-in artificial intelligence: you can ask it to explain a program, write code or make changes across several files at once. It comes with its own models, but it also lets you use yours: paid models through OpenRouter and free or local models through LiteLLM.
This guide takes you from installing Cursor to having your models available in its selector. It's the most advanced guide in the series, because you have to publish your LiteLLM on the Internet securely, but every step is explained.
What you should know before you start
Three conditions are worth knowing from the start, because they shape everything else:
- Using your own models in Cursor requires a paid plan. Since 2026, Cursor only accepts your own keys on the Pro plan ($20 a month) or higher. On the free (Hobby) plan, keys don't work even if they're set up correctly.
- Cursor can't reach your computer directly. Requests to your models go through Cursor's servers, so the address you give it must be public, reachable from the Internet. An address like
http://localhost:4000won't work. In this guide we'll use Tailscale Funnel to publish LiteLLM securely. - Cursor only accepts one custom address at a time. So if you want to mix OpenRouter models with free or local models, the cleanest way is to put all of them behind LiteLLM and give Cursor only LiteLLM's address.
Also, your models are used in Cursor's chat and agent. Autocomplete while you type (Tab) always uses Cursor's own models.
What you will build
Cursor → Cursor's servers → Internet (Tailscale Funnel) → LiteLLM on your computer
├─ OpenRouter (paid models)
├─ OpenRouter (free :free models)
└─ Ollama (local models)You need LiteLLM installed (there's a guide on this blog). If you only want paid OpenRouter models and don't care about LiteLLM, skip to "Shortcut: OpenRouter only, without LiteLLM" at the end.
Step 1. Install Cursor
- Go to cursor.com/downloads.
- Download the version for your system:
- Mac: "Mac Universal" (works on any Mac with macOS 12 or later). Open the
.dmgand drag Cursor into Applications. - Windows: the "(User)" installer for your processor type (x64 on most computers). Open it and follow the installer. You need Windows 10 or later.
- Linux: the
.deb(Ubuntu, Debian) or.rpm(Fedora) package installs with a double-click. There's also an AppImage: make it executable withchmod +x Cursor-*.AppImageand open it.
- Open Cursor. It asks you to sign in or create an account: this is required.
- If you used Visual Studio Code before, you can import your settings and extensions in Cursor Settings → General → Account → VS Code Import.
To use your own models, subscribe to the Pro plan at cursor.com/pricing.
Step 2. Set up OpenRouter
OpenRouter is a service that gives access, with a single account, to hundreds of paid models (from Anthropic, OpenAI, Google and others) and about twenty free ones.
- Create an account at openrouter.ai.
- If you'll use paid models, add credit at openrouter.ai/settings/credits. OpenRouter charges each model's price with no markup, plus a small fee when you buy credit (5.5% by card).
- Create a key at openrouter.ai/settings/keys with Create Key. Give it a credit limit: it's your insurance against surprises. Copy the key (it starts with
sk-or-).
OpenRouter model names have the form company/model. Some current examples:
- Paid:
anthropic/claude-sonnet-5,openai/gpt-5.6-sol,google/gemini-3.1-pro-preview,deepseek/deepseek-v4-pro. - Free:
qwen/qwen3.8-27b:free,nvidia/nemotron-3-super-120b-a12b:free.
The list changes often: check exact names and prices at openrouter.ai/models.
Step 3. Add the models to LiteLLM
Open the config.yaml file in your LiteLLM folder (the LiteLLM guide explains how). Make it look like this, replacing the keys with yours:
model_list:
- model_name: or-sonnet-5
litellm_params:
model: openrouter/anthropic/claude-sonnet-5
api_key: sk-or-YOUR-OPENROUTER-KEY
- model_name: or-gpt-sol
litellm_params:
model: openrouter/openai/gpt-5.6-sol
api_key: sk-or-YOUR-OPENROUTER-KEY
- model_name: free-qwen
litellm_params:
model: openrouter/qwen/qwen3.8-27b:free
api_key: sk-or-YOUR-OPENROUTER-KEY
- model_name: local-qwen
litellm_params:
model: ollama_chat/qwen3.5
api_base: http://localhost:11434
general_settings:
master_key: sk-my-switchboard-8f3k29dq7wThree important details:
- Use your own names that don't match Cursor's. Cursor rejects a custom model whose name matches one of its models, and it treats names containing brands such as "gpt", "claude" or "gemini" in a special way. Neutral names like
or-sonnet-5orfree-qwenavoid problems. - The local model needs a lot of context memory. Cursor sends about 25,000 tokens with each request. If you use an Ollama model, raise its context length to 64,000 or more (in Ollama's settings) and pick a model your computer can run with that context. Otherwise, remove the
local-qwenblock. - Update LiteLLM. Cursor's agent mode needs a recent version of LiteLLM. Update it with
uv tool upgrade litellm.
Save the file and start LiteLLM as usual:
litellm --config config.yamlStep 4. Publish LiteLLM on the Internet with Tailscale Funnel
Tailscale is a service, free for personal use, that connects your devices securely. Its Funnel feature publishes a program on your computer at a public https:// address, without opening ports on your router.
Install Tailscale
- Mac and Windows: download it from tailscale.com/download, install it, open it and sign in (you can use your Google, Microsoft or Apple account).
- Linux: in the terminal, run:
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale upThe second command shows a link: open it in your browser to sign in.
Open the tunnel
With LiteLLM running, open another terminal window and type:
tailscale funnel 4000On Linux, add sudo in front. On Mac, if the terminal doesn't recognise the tailscale command, look in the Tailscale app's settings for the option to install its command-line tool (CLI).
The first time, Tailscale shows a link to enable Funnel on your account. Open it, accept and run the command again. Then you'll see something like:
Available on the internet:
https://my-computer.your-network.ts.net/
|-- proxy http://127.0.0.1:4000That https://…ts.net address is your LiteLLM's public address. Write it down. Leave this window open: if you close it, the tunnel closes.
Check that it answers from the Internet
In a third terminal window (replace the address and key with yours):
curl https://my-computer.your-network.ts.net/cursor/models -H "Authorization: Bearer sk-my-switchboard-8f3k29dq7w"On Windows, type curl.exe instead of curl. If you see the list with or-sonnet-5, free-qwen and the rest, the path is open.
Step 5. Configure Cursor
- Open Cursor's settings: Cursor Settings (with ⌘ + Shift + J on Mac or Ctrl + Shift + J on Windows and Linux).
- Go to the Models section.
- In OpenAI API Key, paste your LiteLLM master key and turn it on.
- Turn on Override OpenAI Base URL and type your public address ending in
/cursor, for example:
https://my-computer.your-network.ts.net/cursor- Click + Add Custom Model and add, one by one, your model names exactly as they appear in
config.yaml:or-sonnet-5,or-gpt-sol,free-qwen,local-qwen. Check that each one's switch is on.
Step 6. Try it
- Open a project or a folder in Cursor.
- Open the chat panel with ⌘ + L (Mac) or Ctrl + L (Windows and Linux).
- In the panel's model selector, choose one of yours, for example
free-qwen. - Ask something simple: "Explain what this project does".
If it answers, the whole path works. You'll see the request pass through the LiteLLM window.
Going back to Cursor's models
While the OpenAI key and the custom address are on, some of Cursor's own models stop working and show an error like "This model does not support custom API keys". To go back to them, turn off the OpenAI API Key switch in Cursor Settings → Models. Turn it on again when you want to use yours.
Shortcut: OpenRouter only, without LiteLLM
If you only want paid OpenRouter models, you don't need LiteLLM or Tailscale, because OpenRouter is already public:
- In Cursor Settings → Models, paste your OpenRouter key into OpenAI API Key and turn it on.
- Turn on Override OpenAI Base URL with this address:
https://openrouter.ai/api/v1- In + Add Custom Model, add the model's full OpenRouter name, for example
anthropic/claude-sonnet-5.
The drawback is that this way you can't combine it with local models or manage everything from one place.
Known limitations
- A paid plan is required to use your own models.
- Autocomplete (Tab) always uses Cursor's models.
- Attaching images in chat fails while the custom address is on.
- Context: Cursor assumes custom models have a very large context memory. With small models, long conversations may fail: start a new chat when that happens.
- The integration isn't official: Cursor doesn't support gateways such as LiteLLM, and LiteLLM maintains it on a "best effort" basis. A new Cursor version may require updating LiteLLM.
Common problems
- "Named models unavailable. Free plans can only use Auto". You're on the free plan: you need Pro.
- "Access to private networks is forbidden". You entered a local address (
localhostor a home IP). Use the public addresshttps://…ts.net/cursor. - "Trouble connecting to the model provider". Cursor can't reach your address: check that the LiteLLM and
tailscale funnelwindows are still open and that thecurlfrom step 4 works. - "Model name is invalid" or the model doesn't appear. The name in Cursor must be identical to the
model_nameinconfig.yaml. If it matches a Cursor model, change it to a neutral one. - Limit error with a
:freemodel. You've used up the day's free requests. Use a paid model or wait until the next day.
Next steps
You now have Cursor working with the models you choose, paying only for what you use. The next guide shows how to use the new AI model built into macOS and how to connect it to Open WebUI.
Next guide: How to use the AI model built into macOS with fm serve and connect it to Open WebUI