---
title: HTTP 402 Payment Required：意義、歷史與 x402 | RunAPI
description: HTTP 402 Payment Required 狀態碼代表什麼、為何閒置了數十年、如今 API 何時會回傳它，以及 x402 如何把它變成一套付款流程。
url: https://runapi.ai/zh-TW/http-402.md
canonical: https://runapi.ai/zh-TW/http-402
locale: zh-TW
updated: '2026-09-24'
date: '2026-09-24'
site: RunAPI
image: https://runapi.ai/assets/opengraph-bfaaa0f0.png
alternates:
  en: https://runapi.ai/http-402
  zh-CN: https://runapi.ai/zh-CN/http-402
  es: https://runapi.ai/es/http-402
  ja: https://runapi.ai/ja/http-402
  de: https://runapi.ai/de/http-402
  fr: https://runapi.ai/fr/http-402
  pt-BR: https://runapi.ai/pt-BR/http-402
  ko: https://runapi.ai/ko/http-402
  it: https://runapi.ai/it/http-402
  nl: https://runapi.ai/nl/http-402
  pl: https://runapi.ai/pl/http-402
  tr: https://runapi.ai/tr/http-402
  zh-TW: https://runapi.ai/zh-TW/http-402
  zh-HK: https://runapi.ai/zh-HK/http-402
  ar: https://runapi.ai/ar/http-402
  x-default: https://runapi.ai/http-402
---

> HTML version: https://runapi.ai/zh-TW/http-402
> Site index for agents: https://runapi.ai/llms.txt

# HTTP 402 Payment Required：它代表什麼，以及 x402 如何運用它

402 是表示「伺服器處理請求前需要先付款」的 HTTP 狀態碼。在它存在的大部分時間裡，一直沒有標準格式。x402 補上了這一塊。

_更新於 September 24, 2026 · 閱讀時間約 5 分鐘_


## Key takeaways

- 402 Payment Required 是一種用戶端錯誤：請求本身有效，但伺服器要求先付款。
- HTTP/1.1 將 402 保留給未來使用，卻從未定義付款該如何進行，因此各家 API 的用法都不一樣。
- x402 補齊了缺少的部分：一個帶有機器可讀條款的 PAYMENT-REQUIRED 標頭，以及重試時附上的已簽署付款。

## 402 Payment Required 代表什麼

402 回應告訴用戶端：請求本身沒有問題，但付款之前不會被處理。它屬於 4xx 系列，因為下一步需要行動的是用戶端而非伺服器。

402 與 401 Unauthorized、403 Forbidden 不同。401 要求提供憑證，403 直接拒絕請求，402 則要求付款。


## 402 為何閒置這麼久

這個狀態碼是在撰寫 HTTP/1.1 時保留下來的，當時預期某種形式的數位現金會在未來出現。但規範從未說明 402 回應的內容應包含什麼、用戶端又該如何付款，因此瀏覽器從未真正處理過它。

由於缺乏統一格式，真正會回傳 402 的 API 只是把它當成一般錯誤：帳戶點數用完、信用卡遭拒，或達到方案上限。


## 如今 API 何時會回傳 402

你會在兩大類情境中看到 402。

- 帳戶計費錯誤：key 有效，但餘額、點數或訂閱不足以支付這次請求。解決方法是儲值或升級方案。
- 按次計費報價：伺服器回傳付款條款，用戶端付款後即可重試同一個請求。x402 就是這樣運作的。

## x402 如何把 402 變成付款流程

x402 將機器可讀的條款放進 PAYMENT-REQUIRED 標頭：金額、資產、網路與收款地址。用戶端依這些條款簽署一份穩定幣授權，透過 PAYMENT-SIGNATURE 標頭送回，再收到附有 PAYMENT-RESPONSE 收據的回應。

由於整個流程都是一般的 HTTP，擁有錢包的 AI 代理不必註冊或保存 API key，就能為單次 API 呼叫付款。


## 在用戶端處理 402

先檢查是否有 PAYMENT-REQUIRED 標頭。如果有，代表這是 x402 報價，x402 用戶端可以完成付款。如果沒有，請閱讀錯誤訊息：通常表示帳戶需要儲值或更換方案。



## HTTP 402 常見問題

### 402 Payment Required 算是錯誤嗎？

它是 4xx 範圍內的用戶端錯誤，但不代表請求格式有誤。它的意思是：伺服器要求先付款才會繼續處理。

### 402 和 401 有什麼不同？

401 表示伺服器需要有效的憑證，402 表示伺服器需要付款。同一個 API 可以對無效的 key 回傳 401，對餘額不足的有效 key 回傳 402。

### 瀏覽器會自動處理 402 嗎？

不會。瀏覽器會把 402 當成一般錯誤頁面顯示。要自動付款，需要能理解 x402 這類協定的用戶端。

### 哪些 API 會搭配 x402 使用 402？

任何實作 x402 協定的伺服器都可以。RunAPI 在按次計費的 AI 模型端點上回傳 x402 報價，AI 代理因此能以 USDC 支付圖片、影片、音樂與音訊生成。



## 相關頁面

- [專為 AI 模型打造的 x402 API](https://runapi.ai/zh-TW/x402.md) - 在 Base 上以 USDC 按次付費，免 API key。
- [模型目錄](https://runapi.ai/zh-TW/models.md) - RunAPI 上所有可用的模型與端點。
- [開發者文件](https://runapi.ai/zh-TW/docs/guides) - 請求格式、任務輪詢與錯誤碼。
- [定價](https://runapi.ai/zh-TW/pricing.md) - 點數、單次呼叫價格與計費細節。


Claude 訪客：新帳戶可在 30 天內獲得 $1.00 API 贈送額度。每人限領一次，僅用於 API 用量。


## 試試一個真的能付款的 402

不帶 key 向 RunAPI 的按次計費端點送出請求，看看它回傳的 x402 報價。

- [瀏覽模型](https://runapi.ai/zh-TW/models.md)
- [閱讀文件](https://runapi.ai/zh-TW/docs/guides)



---

## More from RunAPI

- [Home](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#all-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)
- [x402 API](https://runapi.ai/zh-TW/x402.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)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```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": "Article",
    "headline": "HTTP 402 Payment Required：意義、歷史與 x402",
    "description": "HTTP 402 Payment Required 狀態碼代表什麼、為何閒置了數十年、如今 API 何時會回傳它，以及 x402 如何把它變成一套付款流程。",
    "datePublished": "2026-09-24",
    "dateModified": "2026-09-24",
    "author": {
      "@type": "Organization",
      "name": "RunAPI"
    },
    "publisher": {
      "@type": "Organization",
      "name": "RunAPI",
      "url": "https://runapi.ai/zh-TW"
    },
    "mainEntityOfPage": "https://runapi.ai/zh-TW/http-402"
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "402 Payment Required 算是錯誤嗎？",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "它是 4xx 範圍內的用戶端錯誤，但不代表請求格式有誤。它的意思是：伺服器要求先付款才會繼續處理。"
        }
      },
      {
        "@type": "Question",
        "name": "402 和 401 有什麼不同？",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "401 表示伺服器需要有效的憑證，402 表示伺服器需要付款。同一個 API 可以對無效的 key 回傳 401，對餘額不足的有效 key 回傳 402。"
        }
      },
      {
        "@type": "Question",
        "name": "瀏覽器會自動處理 402 嗎？",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "不會。瀏覽器會把 402 當成一般錯誤頁面顯示。要自動付款，需要能理解 x402 這類協定的用戶端。"
        }
      },
      {
        "@type": "Question",
        "name": "哪些 API 會搭配 x402 使用 402？",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "任何實作 x402 協定的伺服器都可以。RunAPI 在按次計費的 AI 模型端點上回傳 x402 報價，AI 代理因此能以 USDC 支付圖片、影片、音樂與音訊生成。"
        }
      }
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-TW",
    "@type": "BreadcrumbList",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "首頁",
        "item": "https://runapi.ai/zh-TW"
      },
      {
        "@type": "ListItem",
        "position": 2,
        "name": "HTTP 402",
        "item": "https://runapi.ai/zh-TW/http-402"
      }
    ]
  }
]
```
