---
title: 身分驗證 | RunAPI
description: 建立 API 金鑰並對 RunAPI 請求進行身分驗證。
url: https://runapi.ai/zh-TW/docs/guides/authentication.md
canonical: https://runapi.ai/zh-TW/docs/guides/authentication
locale: zh-TW
---

> HTML 版本: https://runapi.ai/zh-TW/docs/guides/authentication
> 代理程式網站索引: https://runapi.ai/llms.txt

# 身分驗證

RunAPI 使用 API 金鑰對 API 請求進行身分驗證。每筆存取您帳號或建立工作的請求都必須附上金鑰。

## 選擇正確的金鑰

* 標準 API 金鑰可呼叫 Task API、LLM API 及帳戶端點。請[登入](https://runapi.ai/zh-TW/login)後開啟「API 金鑰」頁面以建立一組。
* 管理金鑰可建立及管理標準 API 金鑰與防護欄。請[登入](https://runapi.ai/zh-TW/login)後開啟「管理金鑰」頁面以建立一組，並僅搭配平台管理端點使用。

## 建立 API 金鑰

為每個應用程式設定專屬的金鑰，以便在不中斷其他整合的情況下輪替或撤銷存取權限。金鑰綁定於單一帳號，請求僅能存取該帳號可見的資源。

付費 API 呼叫每帳戶每分鐘限制 300 個請求。
`429 Too Many Requests` 回應會包含 `Retry-After`、
`X-RateLimit-Limit-RPM`、`X-RateLimit-Remaining-RPM` 及
`X-RateLimit-Reset` 標頭。

## 對請求進行身分驗證

在 `Authorization` 標頭中以 Bearer 權杖的形式傳送 API 金鑰：

```http
Authorization: Bearer YOUR_API_TOKEN
```

例如，使用 cURL 查詢您目前的餘額：

```shell
curl "https://runapi.ai/api/v1/me/balance" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

## 託管 MCP OAuth

遠端 MCP 用戶端連接至 `https://mcp.runapi.ai/mcp`，並使用標準 OAuth 資源 `https://mcp.runapi.ai` 自動探索 RunAPI 授權流程。登入或建立 RunAPI 帳戶，選擇一個帳戶並核准存取，無需建立或共用 API 金鑰。

RunAPI 支援動態用戶端註冊、搭配 S256 PKCE 的授權碼流程，以及用於 Hosted MCP 存取的輪換重新整理權杖。

OAuth 探索端點：

* 受保護資源中繼資料：
  `https://runapi.ai/.well-known/oauth-protected-resource`
* 授權伺服器中繼資料：
  `https://runapi.ai/.well-known/oauth-authorization-server`

[登入](https://runapi.ai/zh-TW/login)，然後在 `/settings#oauth-connections` 開啟「已授權的應用程式」，以檢視或撤銷用戶端存取權限。

## 妥善保管金鑰

* 將 API 金鑰存放於密鑰管理員或加密的憑證儲存區中。
* 絕對不要將金鑰提交至版本控制，或在瀏覽器程式碼中公開。
* 若金鑰可能已外洩，請立即輪換。
* 開發環境與正式環境請使用不同的金鑰。

## 疑難排解身分驗證

* `401 Unauthorized` 回應表示金鑰遺失、格式錯誤、已撤銷或無效。
* `403 Forbidden` 回應表示金鑰有效，但其憑證類別或帳戶角色無法執行該操作。
* 確認標頭以 `Bearer` 開頭，後接一個空格及完整金鑰。
* 確認該金鑰屬於您所請求資源的帳戶。

---

## RunAPI 的更多內容

- [首頁](https://runapi.ai/zh-TW/.md)
- [模型目錄](https://runapi.ai/zh-TW/models.md)
- [價格](https://runapi.ai/zh-TW/pricing.md)
- [提供商](https://runapi.ai/zh-TW/models)
- [文件](https://runapi.ai/zh-TW/docs/guides)
- [SDK](https://runapi.ai/zh-TW/sdk.md)
- [CLI](https://runapi.ai/zh-TW/cli.md)
- [MCP Server](https://runapi.ai/zh-TW/mcp.md)
- [Claude Code 與 Cursor](https://runapi.ai/zh-TW/claude-code-vs-cursor.md)
- [Cursor API 設定](https://runapi.ai/zh-TW/cursor-api-setup.md)
- [RunAPI 與 OpenRouter](https://runapi.ai/zh-TW/openrouter-alternative.md)
- [企業版](https://runapi.ai/zh-TW/contact.md)
- [聯絡我們](https://runapi.ai/zh-TW/contact.md)
- [服務條款](https://runapi.ai/zh-TW/terms.md)
- [隱私權](https://runapi.ai/zh-TW/privacy.md)
- [代理程式網站索引](https://runapi.ai/llms.txt)

聯絡我們: contact@runapi.ai

## 結構化資料

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-TW/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-TW",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-TWicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "TechArticle",
    "headline": "身分驗證",
    "description": "建立 API 金鑰並對 RunAPI 請求進行身分驗證。",
    "url": "https://runapi.ai/zh-TW/docs/guides/authentication",
    "mainEntityOfPage": "https://runapi.ai/zh-TW/docs/guides/authentication"
  }
]
```
