OpenAI 列出项目支出提醒

2026-11-17 18:24 更新

列出项目支出提醒

get /organization/projects/{project_id}/spend_alerts

列出项目支出提醒。

路径参数

  • project_id: string

要查看的项目 ID。

查询参数

  • after: optional string

分页游标。提供上次响应中最后一条支出提醒的 ID,以获取下一页。

  • before: optional string

分页游标。提供上次响应中第一条支出提醒的 ID,以获取上一页。

  • limit: optional integer

返回的支出提醒数量上限,默认为20。

minimum: 0, maximum: 100

  • order: optional "asc" or "desc" (default: "asc")

返回的支出提醒的排序顺序。

  • "asc"

  • "desc"

返回值

  • data: array of ProjectSpendAlert

当前页返回的支出提醒。

  • id: string

标识符,可在 API 端点中引用。

  • currency: "USD"

阈值金额所用的币种。

  • "USD"

  • interval: "month"

用于评估支出是否达到阈值的时间区间。

  • "month"

  • notification_channel: object { recipients, type, subject_prefix }

支出提醒的电子邮件通知设置。

  • recipients: array of string

接收支出提醒通知的电子邮件地址。

  • type: "email"

通知渠道类型。目前仅支持 email。

  • "email"

  • subject_prefix: optional string or null

提醒邮件的可选主题前缀。

  • object: "project.spend_alert"

对象类型,固定为 project.spend_alert。

  • "project.spend_alert"

  • threshold_amount: integer

提醒阈值金额,单位为美分。

  • first_id: string or null

本页第一条支出提醒的 ID。

  • has_more: boolean

分页时是否还有更多支出提醒可用。

  • last_id: string or null

本页最后一条支出提醒的 ID。

  • object: "list"

固定为 list。

  • "list"

示例

## 从环境变量读取管理员密钥;先把项目、资源 ID 和请求参数替换为实际值
curl "https://api.openai.com/v1/organization/projects/$PROJECT_ID/spend_alerts" \
    -H "Authorization: Bearer $OPENAI_ADMIN_KEY"

200 — 示例

{
  "data": [
    {
      "id": "id",
      "currency": "USD",
      "interval": "month",
      "notification_channel": {
        "recipients": [
          "string"
        ],
        "type": "email",
        "subject_prefix": "示例主题前缀"
      },
      "object": "project.spend_alert",
      "threshold_amount": 0
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

示例

## 从环境变量读取管理员密钥;先把项目、资源 ID 和请求参数替换为实际值
curl "https://api.openai.com/v1/organization/projects/proj_abc/spend_alerts?limit=20&order=asc" \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json"

响应示例

{
    "object": "list",
    "data": [
        {
            "id": "alert_abc123",
            "object": "project.spend_alert",
            "threshold_amount": 100000,
            "currency": "USD",
            "interval": "month",
            "notification_channel": {
                "type": "email",
                "recipients": ["finance@example.com"],
                "subject_prefix": "OpenAI 支出提醒"
            }
        }
    ],
    "first_id": "alert_abc123",
    "last_id": "alert_abc123",
    "has_more": false
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号