Home / Guides / Coding tools

Use DeepSeek and GLM in Cursor with your own API key

Updated 2026-12-04 · Set up Cursor's OpenAI API key and base URL override for DeepSeek and GLM: step by step, what the override affects, model choice and fixes.

Connection details

Base URL (OpenAI compatible)
https://api.aifans.fan/v1
API key
Create one in the console; it starts with sk- (no account yet? sign up)
Recommended models
deepseek-v4.1-flash, glm-5.3 (all models and prices)

Cursor can send its chat and agent requests to any OpenAI-compatible API: you give it an API key, turn on Override OpenAI Base URL and add the model names you want. With AIFans API that gives Cursor's Chat and Agent deepseek-v4.1-flash and glm-5.3, billed per token in US dollars.

Before you start

  • Cursor sends bring-your-own-key requests through its own servers, so the API has to be reachable on the public internet. Ours is: https://api.aifans.fan/v1.
  • Your custom models are used in Chat and Agent. Tab completion always uses Cursor's own models.
  • Create a AIFans API key for Cursor in the console (sign up first if needed) and give it a daily spending limit.

Step 1: add the API key and base URL

  1. Open Cursor Settings (Ctrl+Shift+J, on macOS Cmd+Shift+J) and go to Models.
  2. Find the API Keys section. Switch on OpenAI API Key and paste your AIFans API key.
  3. Switch on Override OpenAI Base URL and enter https://api.aifans.fan/v1.

Step 2: add the models

  1. In the model list, click Add model (older versions: Add Custom Model).
  2. Enter deepseek-v4.1-flash exactly as written, lower case. Add glm-5.3 the same way for harder tasks.
  3. Make sure the new models are switched on.

Step 3: pick the model and test

Open the Chat or Agent panel (Ctrl+L / Cmd+L), choose deepseek-v4.1-flash in the model picker and send a short message. Then ask the agent to read a file in your project: that proves tool calls work too. Each request shows up in the console's Usage page within a few seconds.

Cursor's menus move between releases; if a label differs, look for the same three settings: OpenAI API key, base URL override and custom model name.

What to know about the override

  • It applies to more than your custom models. While it is on, Cursor sends every model that is not a Claude or Gemini model to the overridden address, including Cursor's own models such as Composer. Those will fail with an “invalid API key” error. Switch the override off to use them, and on again for AIFans API.
  • Auto mode may not use your key. Pick your model by name in the picker.
  • Request formats. Depending on the version, Cursor sends tool definitions and agent requests in shapes that are not standard Chat Completions, which is why many OpenAI-compatible APIs return 400 errors to Cursor. Our API accepts these formats on the normal /v1 address, so there is no special Cursor URL to remember.
  • Privacy. Requests pass through Cursor before they reach us, so Cursor's own privacy settings apply to them as well as ours.

Which model to use

Model ID and useInputCached inputOutputContext
deepseek-v4.1-flash
Everyday coding: the best price for long agent sessions, with cheap cached input
$0.195$0.0039$0.781M
glm-5.3
Harder work: planning, large refactors, tricky bugs
$0.812$0.1508$2.5521M
glm-5.3-flash
Quick edits and high-volume jobs at the lowest price
$0.087$0.0174$0.291M
minimax-m3.1-flash
A fast alternative for routine agent steps
$0.15$0.015$0.6—

USD per 1M tokens. Prices are read from our live price list; all models and prices.

Agent mode resends the conversation on each step; most of it is a cache hit, billed at the cached-input price. Starting a new chat when you switch tasks keeps each step cheap.

Troubleshooting

  • “Invalid API key” or “Unauthorized User API key” on a Cursor model. Expected while the override is on; switch to one of your custom models, or switch the override off.
  • The key check in settings fails, but you added a model. Cursor may test the key with one of its default OpenAI model names, which we do not serve. Send a chat message with your custom model: that is the real test.
  • 404 model_not_found. The model name must match exactly; copy it from the models page.
  • 401. The key was not pasted in full, or was disabled in the console.
  • 402. Your balance is used up; top up in the console.
  • 429. Too many requests per minute on one key (100 by default). Cursor retries; throttled calls are not billed.

FAQ

Do I need a paid Cursor plan?

Cursor decides which plans allow your own API key, and that has changed over time; check your plan in Cursor. Your usage with us is billed by us, per token.

Does Tab autocomplete use these models?

No. Tab always runs on Cursor's own models; only Chat and Agent use your custom models.

Can I use Claude models in Cursor at the same time?

Yes. Claude and Gemini models in Cursor use their own key settings, so they are not affected by the OpenAI override.

Can I use localhost or a private network address?

Not with Cursor's override, because requests are sent from Cursor's servers. Our address, https://api.aifans.fan/v1, is public.

Related guides