Skip to content
Start here

Policies

List policies
GET/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies
Get a policy
GET/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies/{id}
Create a policy
POST/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies
Edit a policy
PATCH/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies/{id}
Delete a policy
DELETE/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies/{id}
ModelsExpand Collapse
PolicyListResponse object { id, action, actor, 6 more }
id: string

The policy ID.

formatuuid
action: object { type } or object { type, except } or object { amount, technique, type, 3 more }

What the policy does to matching requests.

One of the following:
Type object { type }
type: "no-limit"

Allow matching requests with no limit.

object { type, except }
type: "block"

Block matching requests.

except: optional boolean

When true, block requests that do not match resource instead.

object { amount, technique, type, 3 more }
amount: number

The spend limit in USD.

exclusiveMinimum
minimum0
technique: "fixed" or "sliding" or "named-interval"

How the limit resets: sliding covers the last window seconds, fixed resets every window seconds, and named-interval resets at the start of each period.

One of the following:
"fixed"
"sliding"
"named-interval"
type: "limit"

Limit spend over a time window or a calendar period.

alerts: optional array of object { percentage }

Up to 5 alerts. Only for named-interval.

percentage: number

The share of the limit, in whole percent, at which to alert.

maximum100
minimum1
period: optional "monthly" or "weekly" or "daily" or "hourly"

A UTC calendar period. Required for named-interval, and only for it.

One of the following:
"monthly"
"weekly"
"daily"
"hourly"
window: optional number

The window length in seconds. Required for fixed and sliding, and only for them.

exclusiveMinimum
minimum0
actor: string

Who the policy applies to: a template whose {…} parts are CEL, such as {cf.user.email}. Each value gets its own spend limit.

condition: string

A CEL expression over cf and metadata; the policy applies when it is true.

created_at: string

When the policy was created.

formatdate-time
enabled: boolean

Whether the policy applies to requests.

modified_at: string

When the policy was last changed.

formatdate-time
name: string

A label for the policy.

resource: object { models, providers }

The requests the policy applies to. Omit both fields to match every request.

models: optional array of string

The models to match. Omit to match every model.

providers: optional array of string

The providers to match. Omit to match every provider. With models, list exactly one.

PolicyGetResponse object { id, action, actor, 6 more }

The policy.

id: string

The policy ID.

formatuuid
action: object { type } or object { type, except } or object { amount, technique, type, 3 more }

What the policy does to matching requests.

One of the following:
Type object { type }
type: "no-limit"

Allow matching requests with no limit.

object { type, except }
type: "block"

Block matching requests.

except: optional boolean

When true, block requests that do not match resource instead.

object { amount, technique, type, 3 more }
amount: number

The spend limit in USD.

exclusiveMinimum
minimum0
technique: "fixed" or "sliding" or "named-interval"

How the limit resets: sliding covers the last window seconds, fixed resets every window seconds, and named-interval resets at the start of each period.

One of the following:
"fixed"
"sliding"
"named-interval"
type: "limit"

Limit spend over a time window or a calendar period.

alerts: optional array of object { percentage }

Up to 5 alerts. Only for named-interval.

percentage: number

The share of the limit, in whole percent, at which to alert.

maximum100
minimum1
period: optional "monthly" or "weekly" or "daily" or "hourly"

A UTC calendar period. Required for named-interval, and only for it.

One of the following:
"monthly"
"weekly"
"daily"
"hourly"
window: optional number

The window length in seconds. Required for fixed and sliding, and only for them.

exclusiveMinimum
minimum0
actor: string

Who the policy applies to: a template whose {…} parts are CEL, such as {cf.user.email}. Each value gets its own spend limit.

condition: string

A CEL expression over cf and metadata; the policy applies when it is true.

created_at: string

When the policy was created.

formatdate-time
enabled: boolean

Whether the policy applies to requests.

modified_at: string

When the policy was last changed.

formatdate-time
name: string

A label for the policy.

resource: object { models, providers }

The requests the policy applies to. Omit both fields to match every request.

models: optional array of string

The models to match. Omit to match every model.

providers: optional array of string

The providers to match. Omit to match every provider. With models, list exactly one.

PolicyCreateResponse object { id, action, actor, 6 more }

The policy.

id: string

The policy ID.

formatuuid
action: object { type } or object { type, except } or object { amount, technique, type, 3 more }

What the policy does to matching requests.

One of the following:
Type object { type }
type: "no-limit"

Allow matching requests with no limit.

object { type, except }
type: "block"

Block matching requests.

except: optional boolean

When true, block requests that do not match resource instead.

object { amount, technique, type, 3 more }
amount: number

The spend limit in USD.

exclusiveMinimum
minimum0
technique: "fixed" or "sliding" or "named-interval"

How the limit resets: sliding covers the last window seconds, fixed resets every window seconds, and named-interval resets at the start of each period.

One of the following:
"fixed"
"sliding"
"named-interval"
type: "limit"

Limit spend over a time window or a calendar period.

alerts: optional array of object { percentage }

Up to 5 alerts. Only for named-interval.

percentage: number

The share of the limit, in whole percent, at which to alert.

maximum100
minimum1
period: optional "monthly" or "weekly" or "daily" or "hourly"

A UTC calendar period. Required for named-interval, and only for it.

One of the following:
"monthly"
"weekly"
"daily"
"hourly"
window: optional number

The window length in seconds. Required for fixed and sliding, and only for them.

exclusiveMinimum
minimum0
actor: string

Who the policy applies to: a template whose {…} parts are CEL, such as {cf.user.email}. Each value gets its own spend limit.

condition: string

A CEL expression over cf and metadata; the policy applies when it is true.

created_at: string

When the policy was created.

formatdate-time
enabled: boolean

Whether the policy applies to requests.

modified_at: string

When the policy was last changed.

formatdate-time
name: string

A label for the policy.

resource: object { models, providers }

The requests the policy applies to. Omit both fields to match every request.

models: optional array of string

The models to match. Omit to match every model.

providers: optional array of string

The providers to match. Omit to match every provider. With models, list exactly one.

PolicyEditResponse object { id, action, actor, 6 more }

The policy.

id: string

The policy ID.

formatuuid
action: object { type } or object { type, except } or object { amount, technique, type, 3 more }

What the policy does to matching requests.

One of the following:
Type object { type }
type: "no-limit"

Allow matching requests with no limit.

object { type, except }
type: "block"

Block matching requests.

except: optional boolean

When true, block requests that do not match resource instead.

object { amount, technique, type, 3 more }
amount: number

The spend limit in USD.

exclusiveMinimum
minimum0
technique: "fixed" or "sliding" or "named-interval"

How the limit resets: sliding covers the last window seconds, fixed resets every window seconds, and named-interval resets at the start of each period.

One of the following:
"fixed"
"sliding"
"named-interval"
type: "limit"

Limit spend over a time window or a calendar period.

alerts: optional array of object { percentage }

Up to 5 alerts. Only for named-interval.

percentage: number

The share of the limit, in whole percent, at which to alert.

maximum100
minimum1
period: optional "monthly" or "weekly" or "daily" or "hourly"

A UTC calendar period. Required for named-interval, and only for it.

One of the following:
"monthly"
"weekly"
"daily"
"hourly"
window: optional number

The window length in seconds. Required for fixed and sliding, and only for them.

exclusiveMinimum
minimum0
actor: string

Who the policy applies to: a template whose {…} parts are CEL, such as {cf.user.email}. Each value gets its own spend limit.

condition: string

A CEL expression over cf and metadata; the policy applies when it is true.

created_at: string

When the policy was created.

formatdate-time
enabled: boolean

Whether the policy applies to requests.

modified_at: string

When the policy was last changed.

formatdate-time
name: string

A label for the policy.

resource: object { models, providers }

The requests the policy applies to. Omit both fields to match every request.

models: optional array of string

The models to match. Omit to match every model.

providers: optional array of string

The providers to match. Omit to match every provider. With models, list exactly one.

PolicyDeleteResponse object { id }

The deleted policy.

id: string

The ID of the deleted policy.

PoliciesUsage

Get policy usage
GET/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/policies/{id}/usage
ModelsExpand Collapse
UsageGetResponse object { end, start, total_cost, 2 more }

The policy’s usage.

end: string

The end of the range used.

formatdate-time
start: string

The start of the range used.

formatdate-time
total_cost: number

The total spend in USD.

total_requests: number

The total requests matched.

usage_by_dimension: map[array of object { cost, requests, value } ]

Usage per value, keyed by each dimension in the policy’s actor.

cost: number

The spend in USD for this value.

requests: number

The requests matched for this value.

value: string

A value of the actor’s dimension.