---
title: HTTP 402 Payment Required：含义、历史与 x402 | RunAPI
description: HTTP 402 Payment Required 状态码的含义、为什么它被闲置了几十年、现在 API 何时会返回它，以及 x402 如何把它变成一套支付流程。
url: https://runapi.ai/zh-CN/http-402.md
canonical: https://runapi.ai/zh-CN/http-402
locale: zh-CN
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-CN/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 报价，智能体因此可以用 USDC 支付图像、视频、音乐和音频生成。



## 相关页面

- [面向 AI 模型的 x402 API](https://runapi.ai/zh-CN/x402.md) - 在 Base 上以 USDC 按请求付费，无需 API key。
- [模型目录](https://runapi.ai/zh-CN/models.md) - RunAPI 上所有可用的模型和端点。
- [开发者文档](https://runapi.ai/zh-CN/docs/guides) - 请求格式、任务轮询和错误码。
- [定价](https://runapi.ai/zh-CN/pricing.md) - 额度、单次调用价格和计费细节。


Claude 访客：新账户可在 30 天内获得 $1.00 API 赠送额度。每人限领一次，仅用于 API 用量。


## 体验一个真正能付款的 402

不带 key 向 RunAPI 的按次计费端点发送一个请求，看看它返回的 x402 报价。

- [浏览模型](https://runapi.ai/zh-CN/models.md)
- [阅读文档](https://runapi.ai/zh-CN/docs/guides)



---

## More from RunAPI

- [Home](https://runapi.ai/zh-CN/.md)
### 产品
- [模型目录](https://runapi.ai/zh-CN/models.md)
- [定价](https://runapi.ai/zh-CN/pricing.md)
- [提供方](https://runapi.ai/zh-CN/models#all-models)
### 开发者
- [文档](https://runapi.ai/zh-CN/docs/guides)
- [SDK](https://runapi.ai/zh-CN/sdk.md)
- [CLI](https://runapi.ai/zh-CN/cli.md)
- [MCP Server](https://runapi.ai/zh-CN/mcp.md)
### 指南
- [Claude Code 与 Cursor](https://runapi.ai/zh-CN/claude-code-vs-cursor.md)
- [Cursor API 设置](https://runapi.ai/zh-CN/cursor-api-setup.md)
- [RunAPI 与 OpenRouter](https://runapi.ai/zh-CN/openrouter-alternative.md)
- [x402 API](https://runapi.ai/zh-CN/x402.md)
### 公司
- [企业版](https://runapi.ai/zh-CN/contact.md)
- [联系](https://runapi.ai/zh-CN/contact.md)
### 法律
- [服务条款](https://runapi.ai/zh-CN/terms.md)
- [隐私政策](https://runapi.ai/zh-CN/privacy.md)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-CN/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-CNicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@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-CN"
    },
    "mainEntityOfPage": "https://runapi.ai/zh-CN/http-402"
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@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 报价，智能体因此可以用 USDC 支付图像、视频、音乐和音频生成。"
        }
      }
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "BreadcrumbList",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "首页",
        "item": "https://runapi.ai/zh-CN"
      },
      {
        "@type": "ListItem",
        "position": 2,
        "name": "HTTP 402",
        "item": "https://runapi.ai/zh-CN/http-402"
      }
    ]
  }
]
```
