# 如何在 Cursor IDE 中使用自己的 API 金鑰

Cursor Pro costs $20/month with a usage cap. With a RunAPI key you pay per token — the same Claude and GPT-4o models at 50% off official rates, no monthly fee, no Pro subscription required. This guide covers where to paste your key in Settings &gt; Models, how to set the base URL (the step most guides skip), and how to fix the common &#39;unauthorized user api key&#39; error.

*Updated June 23, 2026 · RunAPI 編輯部*

## Cursor 可以使用自己的 API 金鑰嗎？

Yes. Cursor lets you add your own API key on the free plan — you do not need Cursor Pro. Go to Settings &gt; Models, scroll to the OpenAI section, and fill in two fields: the OpenAI Base URL (https://runapi.ai/v1) and the OpenAI API Key (your RunAPI key). RunAPI gives you access to Claude 3.5 Sonnet, GPT-4o, Gemini, and other models at 50% of what Anthropic and OpenAI charge directly. The most common setup error — the &#39;unauthorized user api key&#39; message — means the base URL field is empty, so Cursor is sending your key to the wrong endpoint.

- **適用於所有 Cursor 方案**: You do not need a Pro subscription to use your own API key. BYOK works on the free Cursor tier and on Pro.
- **OpenAI 相容端點**: RunAPI uses the same request and response format as the OpenAI API. Cursor&#39;s OpenAI API Key field accepts it without any code changes.
- **官方模型定價五折**: RunAPI 的計費費率為官方定價的一半。透過 RunAPI，Claude 3.5 Sonnet 輸入費用為 $1.50/M tokens，而直接透過 Anthropic 則為 $3.00/M tokens。
- **修復「unauthorized user api key」**: This error almost always means the OpenAI Base URL field is empty. Set it to https://runapi.ai/v1 alongside your key and the error clears.

## 如何在 Cursor 中輸入 API 金鑰

Cursor keeps all model configuration in one place. Open Cursor, press Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows/Linux) to open Settings, then click the Models tab on the left. Find the OpenAI section — you need to fill in two fields there. The OpenAI Base URL tells Cursor to send requests to RunAPI instead of OpenAI directly. The OpenAI API Key field is where you paste your RunAPI key. Both fields must be set. If you leave the base URL blank, Cursor sends your key to api.openai.com, which will reject it every time.

## 修復 Cursor 中「unauthorized user api key」錯誤

The &#39;unauthorized user api key&#39; message from Cursor means one of three things. First, the OpenAI Base URL field is empty, so Cursor sends your RunAPI key to api.openai.com, which rejects it — this is the most common cause. Second, the key was copied with a leading or trailing space. Third, the key was revoked or regenerated and the old value is stale. RunAPI keys start with &#39;rp-&#39; and are not standard OpenAI keys — they will always fail if Cursor tries to authenticate them against openai.com. Always set the base URL alongside the key. If a specific model still returns an error after the key and URL are correct, double-check the model name matches the exact slug shown at runapi.ai/pricing — a mismatch returns a different error than an auth failure.

### 缺少 Base URL

最常見的原因。若 OpenAI Base URL 為空，Cursor 會將您的 RunAPI 金鑰傳送至 api.openai.com，而該網址會拒絕此金鑰。將 Base URL 設為 https://runapi.ai/v1 即可解決此錯誤。

### 金鑰複製時帶有多餘空白

Paste the key and look for a leading or trailing space. Some terminals and browsers add invisible whitespace when you copy. Delete the field and paste again if in doubt.

### 金鑰已過期或被撤銷

RunAPI 金鑰可從控制台撤銷。若您近期重新生成了金鑰，舊值將回傳 401 錯誤。請從「Dashboard &gt; API Keys」複製新金鑰。

### 模型識別碼錯誤

若金鑰和 URL 均正確，但特定模型仍回傳錯誤，可能是模型名稱與 RunAPI 的目錄不符。請至 runapi.ai/pricing 確認正確的模型識別碼，並貼入 Cursor 的模型欄位。


## Cursor Pro 每月 $20 是否值得？還是應該使用自己的金鑰？

Cursor Pro gives you a fixed monthly allowance of fast-model requests. Once you hit the cap, Cursor slows you down or stops until the month resets. BYOK with RunAPI has no cap — you pay per token at 50% of official rates. For most developers, the break-even point is around 8–12 hours of heavy AI coding per month. Below that, RunAPI costs less. Above that, a subscription becomes more predictable but not necessarily cheaper.

## 如何在 Cursor 中透過 RunAPI 使用自己的 API 金鑰

1. **建立免費 RunAPI 帳號** — 前往 runapi.ai 並註冊帳號。無需信用卡。您將獲得少量免費額度以測試連接。
2. **複製您的 API 金鑰和 Base URL** — In the RunAPI dashboard, go to API Keys and generate a key. Copy it right away and note the base URL — it is https://runapi.ai/v1.
3. **開啟 Cursor 設定** — In Cursor, press Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows/Linux) to open Settings. Click the Models tab on the left sidebar.
4. **輸入 Base URL** — Scroll to the OpenAI section. Paste https://runapi.ai/v1 into the OpenAI Base URL field. Most guides skip this step — without it, Cursor sends all requests to OpenAI and rejects your key.
5. **Paste your key and click Enable** — Paste your RunAPI key into the OpenAI API Key field. Check that there is no leading or trailing whitespace. Toggle the OpenAI section on if it is off, then click Verify or Enable.
6. **選擇模型並測試** — In the Cursor chat bar, choose a model such as gpt-5.4. Send a test message. A response confirms the connection works. Check your RunAPI dashboard under Usage to see the request logged.

## Cursor API 金鑰設定常見問題

### 為何 Cursor 顯示「unauthorized user api key」？

此錯誤出現時，表示 Cursor 無法向目標端點驗證您的金鑰。最常見的原因是 OpenAI Base URL 欄位為空，導致 Cursor 將您的 RunAPI 金鑰傳送至 api.openai.com，而該網址會拒絕此金鑰。請將 Base URL 設為 https://runapi.ai/v1，並與金鑰一同填寫以修復問題。

### Do I need a Pro version of Cursor to add custom API keys?

No — you do not need a Pro subscription to use your own API key. Cursor lets you add custom API keys on the free plan. Go to Settings &gt; Models, paste your key into the OpenAI API Key field, set the base URL, and you are done. Cursor&#39;s own built-in model requests have separate limits, but those do not apply when you supply your own key.

### 透過 RunAPI 可在 Cursor 中使用哪些模型？

RunAPI 目錄中所有提供對話補全端點的模型均可使用，包括 Claude 3.5 Sonnet、Claude 3.7 Sonnet、GPT-4o、GPT-4.1、Gemini 1.5 Pro 以及 Llama 3.1。請將 runapi.ai/pricing 上的確切模型識別碼輸入至 Cursor 的模型欄位。圖像和音訊模型無法在 Cursor 的對話介面中使用。

### RunAPI 比 Cursor Pro 更便宜嗎？

對於輕度至中度使用者，是的。Cursor Pro 每月 $20，適合希望固定費用的開發者。RunAPI 按 Token 計費，費率為官方定價的 50%——Claude 3.5 Sonnet 輸入費用為 $1.50/M tokens。重度使用者若能維持在 Pro 配額內，訂閱制更易預算，但 RunAPI 不會限速。

### 同一個 RunAPI 金鑰也能在 Windsurf 和 Claude Code 中使用嗎？

可以。同一個 RunAPI 金鑰可在 Cursor、Windsurf、Claude Code、Codex 以及任何支援自訂 OpenAI 相容端點的工具中使用。用量和消費統一顯示在一個 RunAPI 控制台，無需為每個工具分別管理金鑰或餘額。

### 在 Cursor 中需要輸入什麼 OpenAI Base URL？

請設為 https://runapi.ai/v1。啟用 OpenAI 區塊後，Cursor 會對所有模型請求使用此 URL。若未填寫此欄位，Cursor 將改為傳送請求至 api.openai.com，而該網址每次都會拒絕 RunAPI 金鑰並回傳未授權錯誤。

### 在 Cursor 中使用 BYOK 會停用 Cursor 的內建功能嗎？

不會。Cursor 的自動補全、差異視圖和 Agent 功能仍可正常運作。BYOK 只會更改 Cursor 用於對話和行內補全的模型與端點。若您設定了 Cursor 介面預設清單中沒有的模型，請直接在模型選擇器中輸入識別碼。

### 如何確認我的 RunAPI 金鑰在 Cursor 中正常運作？

在 Cursor 對話中傳送一條簡短訊息，然後在 RunAPI 控制台的「Usage」頁面查看。每次請求後幾秒內，便會出現包含模型名稱、Token 數量和費用的新記錄。若無記錄出現，表示 Base URL 或金鑰未能成功連接至 RunAPI。

