Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Update organization spend limit

client.Admin.Organization.SpendLimit.Update(ctx, body) (*OrganizationSpendLimit, error)
POST/organization/spend_limit

Create or replace the organization’s hard spend limit.

ParametersExpand Collapse
body AdminOrganizationSpendLimitUpdateParams

The currency for the threshold amount. Currently, only USD is supported.

The time interval for evaluating spend against the threshold. Currently, only month is supported.

ThresholdAmount param.Field[int64]

The hard spend limit amount, in cents.

minimum1
ReturnsExpand Collapse
type OrganizationSpendLimit struct{…}

Represents a hard spend limit configured at the organization level.

Currency OrganizationSpendLimitCurrency

The currency for the threshold amount. Currently, only USD is supported.

Enforcement OrganizationSpendLimitEnforcement

The current enforcement state of the hard spend limit.

Interval OrganizationSpendLimitInterval

The time interval for evaluating spend against the threshold. Currently, only month is supported.

Object OrganizationSpendLimit

The object type, which is always organization.spend_limit.

ThresholdAmount int64

The hard spend limit amount, in cents.

Update organization spend limit

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  organizationSpendLimit, err := client.Admin.Organization.SpendLimit.Update(context.TODO(), openai.AdminOrganizationSpendLimitUpdateParams{
    Currency: openai.AdminOrganizationSpendLimitUpdateParamsCurrencyUsd,
    Interval: openai.AdminOrganizationSpendLimitUpdateParamsIntervalMonth,
    ThresholdAmount: 1,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationSpendLimit.Currency)
}
{
    "object": "organization.spend_limit",
    "threshold_amount": 10000,
    "currency": "USD",
    "interval": "month",
    "enforcement": {
        "status": "enforcing"
    }
}
Returns Examples
{
    "object": "organization.spend_limit",
    "threshold_amount": 10000,
    "currency": "USD",
    "interval": "month",
    "enforcement": {
        "status": "enforcing"
    }
}