codecamp

OpenAI 更新项目支出提醒

更新项目支出提醒

post /organization/projects/{project_id}/spend_alerts/{alert_id}

更新项目支出提醒。

路径参数

  • project_id: string

要更新的项目 ID。

  • alert_id: string

要更新的支出提醒 ID。

请求体参数

内容类型:application/json

  • 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

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

  • threshold_amount: integer

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

minimum: 0

返回值

  • ProjectSpendAlert object { id, currency, interval, 3 more }

表示在项目级别配置的支出提醒。

  • 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

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

示例

## 使用环境变量中的组织管理员密钥更新项目支出提醒
curl -X POST "https://api.openai.com/v1/organization/projects/proj_abc/spend_alerts/alert_abc123" \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "threshold_amount": 150000,
      "currency": "USD",
      "interval": "month",
      "notification_channel": {
          "type": "email",
          "recipients": ["finance@example.com"],
          "subject_prefix": "OpenAI 支出提醒"
      }
  }'

响应示例

{
    "id": "alert_abc123",
    "object": "project.spend_alert",
    "threshold_amount": 150000,
    "currency": "USD",
    "interval": "month",
    "notification_channel": {
        "type": "email",
        "recipients": ["finance@example.com"],
        "subject_prefix": "OpenAI 支出提醒"
    }
}
OpenAI 获取项目支出提醒
OpenAI 删除项目支出提醒
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

其他能力与进阶指南

Embeddings 接口参考

审计日志接口参考

项目管理及子资源接口参考

Agents 接口及子资源

Decisions 接口参考

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }