This article teaches you how to connect OpenAI Hub’s API in the Cursor editor so you can call Claude, GPT, Gemini, and other major models with a single key.
What You Need
- Cursor Pro or higher subscription — The free version doesn’t support custom Base URLs; without this, the rest won’t work.
- OpenAI Hub API Key — Register at openai-hub.com to get one.
Step 1: Open Cursor Model Settings
Click the gear icon in the upper-right corner of Cursor to open the settings panel, then select the Models tab.
Step 2: Enter the API Key and Base URL
On the Models page, scroll down to find the API Keys section:
- Enter your key in the OpenAI API Key field:
sk-your-api-key
- Enter the following in the Override OpenAI Base URL field:
https://api.openai-hub.com/v1
- Turn on both switches — enable both the
Override OpenAI Base URLandOpenAI API Keytoggles.
Note: This is a common pitfall — many users only enable the Override URL toggle but forget to turn on the API Key toggle. As a result, requests still use Cursor’s built-in usage quota instead of your key. Once both switches are enabled, you should see a yellow warning icon, which indicates the custom URL has taken effect.
Step 3: Add the Models You Want to Use
At the bottom of the model list, find the Add Model button and enter the model name you want to use, for example:
claude-sonnet-4-20250514gpt-4ogemini-2.5-prodeepseek-r1
Note: The model name must exactly match the model ID supported by OpenAI Hub. Even a single extra or missing character will cause an error. Check the OpenAI Hub documentation for the full list of supported models.
After adding models, uncheck the ones you don’t need and keep only the ones you use.
Step 4: Verify That the Configuration Works
Click the Verify button next to your model. If there are no errors, the connection is successful.
Then open the Cursor chat window (the dialog icon in the upper-right corner), select the model you just added, and test it by asking a question.
Configuration Not Working? Check in This Order
| Symptom | Probable Cause |
|---|---|
| Verify returns 401 | API Key is incorrect or the API Key toggle is off |
| Verify returns 404 | Model name is wrong — check it against the OpenAI Hub docs |
| No yellow warning icon | Both toggles aren’t turned on, requests are still using Cursor’s default route |
| Chat works but completion doesn’t | In Models settings, make sure your model is checked for code completion |
Quickly Verify the API in the Terminal
If you’re not sure whether the issue is with Cursor or the API, use curl to rule it out first:
curl https://api.openai-hub.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Tell me a programmer joke"}]
}'
If curl returns a normal result, the API is fine — check Cursor’s configuration. If curl also fails, it’s a key or network issue.
Don’t Want to Buy Cursor Pro? There’s Another Way
If you're using the free version of Cursor and can’t change the Base URL but still want to use OpenAI Hub’s models — you can call them directly in Cursor’s built-in terminal using Python:
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.openai-hub.com/v1"
)
response = client.chat.completions.create(
model="claude-sonnet-4-20250514",
messages=[{"role": "user", "content": "Write a quicksort algorithm in Python"}]
)
print(response.choices[0].message.content)
Although you won’t get Cursor’s native code completion or Composer experience, you can at least use the models.
