š Integrating Cursor with CodingPlanX Custom Models
Introduction: Cursor is an AI-powered code editor deeply loved by developers, featuring powerful built-in Large Language Model (LLM) capabilities. However, due to network restrictions, cost control (using third-party proxy APIs or cheaper models like DeepSeek), or enterprise intranet deployment needs, we often need to configure a custom API URL and API Key.
This tutorial will guide you step-by-step on how to easily complete this configuration.
š Prerequisites
Before starting, please ensure you have the following information ready:
- Installed Cursor: Make sure your Cursor is updated to the latest version.
- API Key: e.g.,
sk-xxxxxxxxxxxxxxxxxxxxxxxx. - Base URL: Your custom API proxy address.
- Note: It usually needs to end with
/v1, for example,https://api.codingplanx.ai/v1.
- Note: It usually needs to end with
- Model Name: The standard name of the model you intend to use (e.g.,
gpt-4o,claude-3-5-sonnet,deepseek-chat, etc.).
āļø Detailed Configuration Steps
Step 1: Open Cursor Settings
- Launch the Cursor editor.
- Click the Gear icon āļø in the top right corner, or use the shortcut to open settings:
- Windows / Linux:
Ctrl+, - macOS:
Cmd+,
- Windows / Linux:
Step 2: Go to the Models Configuration Page
In the left navigation bar of the settings panel, find and click the Models tab.
Step 3: Configure the API Key
- Scroll down the Models page to find the
OpenAI API Keysection. - Paste your custom API Key into the input box.
- Click the
Verifybutton on the right. (If verification fails at this point, don't worry, as we haven't configured the URL yet). - ā ļø Important Note: Please ensure that the official
Cursor Taband other paid subscription toggles above are in the appropriate state (if you are using a free third-party API, it is recommended to turn off the official model toggles).
Step 4: Configure the Base URL (Override Default Endpoint)
This is the most crucial step, as it determines where your requests are sent:
- Below the
OpenAI API Keyinput box, find theOverride OpenAI Base URLoption. - Expand this option and enter your custom interface address into the box.
š” Example Format:
- CodingplanX AI:
https://api.codingplanx.ai/v1
- CodingplanX AI:
- After filling it in, you must press the Enter key to save the settings.
Step 5: Add Custom Model Names (Optional but Recommended)
If the model you are using is not in Cursor's default list (e.g., deepseek-coder), you need to add it manually:
- Scroll to the top of the Models page and find the
Model Namessection. - Click
+ Add Model. - Type your model name accurately (e.g.,
deepseek-chat), then press Enter to confirm. - Toggle on the switch next to the model you just added, and it is recommended to turn off other models you don't use to prevent selecting the wrong one.
ā Testing and Verification
After configuration, we need to test if it works:
- Return to the code editing interface.
- Press
Ctrl + L(Windows) orCmd + L(macOS) to bring up the Chat window on the right. - At the bottom of the chat window, click the currently displayed model name and switch to the model you just configured (e.g.,
gpt-4oordeepseek-chat). - Send a simple greeting, for example:
"Who are you? Please tell me your model version." - If the AI replies normally and quickly, congratulations, the configuration is successful! š
ā FAQ & Troubleshooting
| Symptom | Possible Cause | Solution |
|---|---|---|
| Connection Timeout / 404 Not Found | Base URL format error. | Check if the URL is missing the /v1 suffix, or if /chat/completions was added by mistake. The correct format should be https://xxx.com/v1. |
| Model not found | The requested model name is not supported by your API channel. | Check if the model name selected in Cursor exactly matches the name supported by your API provider (case-sensitive). |
| Authentication failed | Incorrect API Key or insufficient balance. | Check if the Key is copied completely (without extra spaces), and go to the API provider's dashboard to check your account balance. |
| Cannot use Cursor Tab (Autocomplete) | Cursor's inline code completion (Copilot) uses an independent model. | Third-party APIs can only take over Chat and Cmd+K features. Cursor Tab completion typically still relies on official Cursor services or requires special configuration supporting FIM models. |
š Conclusion: Mastering custom API configuration not only significantly reduces the cost of using AI-assisted programming but also allows you to freely switch between various cutting-edge LLMs. If you found this tutorial helpful, feel free to share it with your developer friends!