設定指南

如何在 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 > Models, how to set the base URL (the step most guides skip), and how to fix the common 'unauthorized user api key' error.

更新於 June 23, 2026 RunAPI Editorial
快速概覽

我可以在 Cursor 中使用自己的 API 金鑰嗎?

Yes. Cursor lets you add your own API key on the free plan — you do not need Cursor Pro. Go to Settings > 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 'unauthorized user api key' 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's OpenAI API Key field accepts it without any code changes.

官方模型價格五折

RunAPI 以提供商定價的一半計費。透過 RunAPI 使用 Claude 3.5 Sonnet 輸入費用為每百萬 Token $1.50,而直接透過 Anthropic 則為 $3.00。

修復「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 'unauthorized user api key' 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 'rp-' 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 > API Keys 複製新金鑰。

模型識別碼錯誤

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

Cursor Pro vs BYOK with RunAPI

Cursor Pro 值得每月花 $20 嗎?還是應該使用自己的 API 金鑰?

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 使用自己的 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 > Models, paste your key into the OpenAI API Key field, set the base URL, and you are done. Cursor'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 輸入成本為每百萬 Token $1.50。重度使用者若能維持在 Pro 配額內,訂閱方案可能更可預測,但 RunAPI 沒有流量限制。

我可以在 Windsurf 和 Claude Code 中使用相同的 RunAPI 金鑰嗎?

是的。一個 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 的自動補全、差異檢視和代理功能仍可正常運作。BYOK 只改變 Cursor 聊天和行內補全所使用的模型和端點。若您設定的模型未出現在 Cursor 的預設清單中,請直接在模型選擇器中輸入識別碼。

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

在 Cursor 聊天中發送一則簡短訊息,然後在 RunAPI 儀表板的使用量下確認。每次請求後數秒內,應出現包含模型名稱、Token 數量和費用的新記錄。若沒有記錄,代表 Base URL 或金鑰未能到達 RunAPI。

相關內容

繼續探索

立即開始在 Cursor 中使用您自己的 API 金鑰

RunAPI gives you an OpenAI-compatible API key for Claude, GPT-4o, Gemini, and more at 50% off official rates. Paste it into Cursor's OpenAI API Key field in under two minutes and pay only for what you use.