OpenAI 获取项目支出提醒
2026-11-17 18:24 更新
获取项目支出提醒
get /organization/projects/{project_id}/spend_alerts/{alert_id}
获取项目支出提醒。
路径参数
project_id: string
项目 ID。
alert_id: string
要获取的支出提醒 ID。
返回值
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
提醒阈值金额,单位为美分。
示例
## 从环境变量读取管理员密钥;先把项目、资源 ID 和请求参数替换为实际值
curl "https://api.openai.com/v1/organization/projects/$PROJECT_ID/spend_alerts/$ALERT_ID" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"
200 — 示例
{
"id": "id",
"currency": "USD",
"interval": "month",
"notification_channel": {
"recipients": [
"string"
],
"type": "email",
"subject_prefix": "示例主题前缀"
},
"object": "project.spend_alert",
"threshold_amount": 0
}
示例
## 从环境变量读取管理员密钥;先把项目、资源 ID 和请求参数替换为实际值
curl "https://api.openai.com/v1/organization/projects/proj_abc/spend_alerts/alert_abc123" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json"
响应示例
{
"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 支出提醒"
}
}以上内容是否对您有帮助:

TRAE-AI编程


更多建议: