codex-gateway

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codex Machine Payment Protocol (MPP)

Codex Machine Payment Protocol (MPP)

Use this skill to access the Codex Supergraph without an API key via the MPP challenge flow.
HTTP endpoint
https://graph.codex.io/graphql
Opt-in header
X-Codex-Payment: mpp
Credential header
Authorization: Payment <base64url-credential>
使用此技能可通过 MPP 挑战流程,在无 API 密钥的情况下访问 Codex Supergraph。
说明
HTTP 端点
https://graph.codex.io/graphql
可选启用头
X-Codex-Payment: mpp
凭证头
Authorization: Payment <base64url-credential>

How it works

工作原理

Every MPP request MUST include the header
X-Codex-Payment: mpp
.
Without it the server will not recognize the request as MPP and will not return the 402 challenge — the request will simply fail. This header is required on both the initial challenge request and the credential retry.
  1. Send a GraphQL query with
    X-Codex-Payment: mpp
    (no credential).
  2. Server returns
    402 Payment Required
    with
    WWW-Authenticate: Payment ...
    challenges.
  3. Client solves one challenge and retries with both
    X-Codex-Payment: mpp
    and
    Authorization: Payment <credential>
    .
  4. Server returns GraphQL data +
    Payment-Receipt
    header.
每个 MPP 请求都必须包含头
X-Codex-Payment: mpp
缺少该头的话,服务器不会将请求识别为 MPP 请求,也不会返回 402 挑战——请求会直接失败。该头在初始挑战请求和凭证重试请求中都是必需的。
  1. 发送带有
    X-Codex-Payment: mpp
    的 GraphQL 查询(无凭证)。
  2. 服务器返回
    402 Payment Required
    响应,附带
    WWW-Authenticate: Payment ...
    挑战信息。
  3. 客户端完成其中一个挑战,并重试请求,同时携带
    X-Codex-Payment: mpp
    Authorization: Payment <credential>
    头。
  4. 服务器返回 GraphQL 数据以及
    Payment-Receipt
    头。

Constraints

限制条件

  • Query only. Mutations and subscriptions return
    403
    in MPP mode.
  • If a valid API key or bearer token is also present, API auth takes precedence.
  • Do not reference legacy dashboard onboarding/top-up/balance payment endpoints.
  • 仅支持查询。 在 MPP 模式下,变更(Mutations)和订阅(subscriptions)会返回
    403
    响应。
  • 如果同时存在有效的 API 密钥或承载令牌,API 身份验证会优先生效。
  • 请勿引用旧版控制台的注册/充值/余额支付端点。

Challenge flow

挑战流程

  1. First request (no credential yet):
bash
curl -i -sS https://graph.codex.io/graphql \
  -H "Content-Type: application/json" \
  -H "X-Codex-Payment: mpp" \
  --data-binary '{"query":"query GetNetworks { getNetworks { id name } }"}'
Expected:
402 Payment Required
with multiple
WWW-Authenticate: Payment ...
challenges.
  1. Retry with solved credential:
bash
curl -i -sS https://graph.codex.io/graphql \
  -H "Content-Type: application/json" \
  -H "X-Codex-Payment: mpp" \
  -H "Authorization: Payment <base64url-credential>" \
  --data-binary '{"query":"query GetNetworks { getNetworks { id name } }"}'
Expected: GraphQL data +
Payment-Receipt
header.
  1. 首次请求(尚未有凭证):
bash
curl -i -sS https://graph.codex.io/graphql \
  -H "Content-Type: application/json" \
  -H "X-Codex-Payment: mpp" \
  --data-binary '{"query":"query GetNetworks { getNetworks { id name } }"}'
预期结果:返回
402 Payment Required
响应,附带多个
WWW-Authenticate: Payment ...
挑战信息。
  1. 使用已完成挑战的凭证重试:
bash
curl -i -sS https://graph.codex.io/graphql \
  -H "Content-Type: application/json" \
  -H "X-Codex-Payment: mpp" \
  -H "Authorization: Payment <base64url-credential>" \
  --data-binary '{"query":"query GetNetworks { getNetworks { id name } }"}'
预期结果:返回 GraphQL 数据以及
Payment-Receipt
头。

Rules

规则

  • Always include
    X-Codex-Payment: mpp
    on every MPP request.
    This is the most common mistake — without it, MPP does not activate.
  • Never print raw credentials.
  • Only use MPP for
    query
    operations.
  • For available GraphQL operations and endpoint selection heuristics, see the
    codex-supergraph
    skill.
  • 所有 MPP 请求务必包含
    X-Codex-Payment: mpp
    头。
    这是最常见的错误——缺少该头的话,MPP 不会激活。
  • 切勿打印原始凭证。
  • 仅将 MPP 用于
    query
    操作。
  • 有关可用的 GraphQL 操作和端点选择规则,请查看
    codex-supergraph
    技能。

References

参考资料

FilePurpose
references/mpp-flow.mdAuth matrix, challenge details, error codes
references/mpp-templates.mdMPP curl templates
references/wallets.mdWallet setup: tempo wallet/request (Tempo) and awal (Base)
文件用途
references/mpp-flow.md身份验证矩阵、挑战详情、错误代码
references/mpp-templates.mdMPP curl 模板
references/wallets.md钱包设置:Tempo 钱包/请求(Tempo)和 awal(Base)