Skip to content
Start here

Update a gateway

PUT/accounts/{account_id}/ai-gateway/gateways/{id}

Updates the configuration of an AI Gateway, such as its caching, rate limiting, logging, and authentication settings.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
AI Gateway Write
Path ParametersExpand Collapse
account_id: string
id: string

Unique identifier of the AI Gateway within the account.

maxLength64
minLength1
Body ParametersJSONExpand Collapse
cache_invalidate_on_update: boolean
cache_ttl: number
minimum0
collect_logs: boolean
rate_limiting_interval: number
minimum0
rate_limiting_limit: number
minimum0
authentication: optional boolean
byok_only: optional boolean

Requires customer-provided provider credentials and prevents fallback to Unified Billing.

dlp: optional object { action, enabled, profiles } or object { enabled, policies }
One of the following:
object { action, enabled, profiles }
action: "BLOCK" or "FLAG"
One of the following:
"BLOCK"
"FLAG"
enabled: boolean
profiles: array of string
object { enabled, policies }
enabled: boolean
policies: array of object { id, action, check, 2 more }
id: string
action: "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
check: array of "REQUEST" or "RESPONSE"
One of the following:
"REQUEST"
"RESPONSE"
enabled: boolean
profiles: array of string
guardrails: optional object { prompt, response }
prompt: object { P1, S1, S10, 11 more }
P1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S10: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S11: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S12: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S13: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S2: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S3: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S4: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S5: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S6: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S7: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S8: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S9: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
response: object { P1, S1, S10, 11 more }
P1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S10: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S11: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S12: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S13: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S2: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S3: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S4: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S5: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S6: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S7: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S8: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S9: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
log_classification: optional boolean
log_management: optional number
maximum10000000
minimum10000
log_management_strategy: optional "STOP_INSERTING" or "DELETE_OLDEST"
One of the following:
"STOP_INSERTING"
"DELETE_OLDEST"
logpush: optional boolean
logpush_public_key: optional string
maxLength1024
minLength16
otel: optional array of object { headers, url, authorization, content_type }
headers: map[string]
url: string
formaturi
maxLength2048
authorization: optional string
maxLength256
content_type: optional "json" or "protobuf"
One of the following:
"json"
"protobuf"
rate_limiting_technique: optional "fixed" or "sliding"
One of the following:
"fixed"
"sliding"
retry_backoff: optional "constant" or "linear" or "exponential"

Backoff strategy for retry delays

One of the following:
"constant"
"linear"
"exponential"
retry_delay: optional number

Delay between retry attempts in milliseconds (0-60000)

maximum60000
minimum0
retry_max_attempts: optional number

Maximum number of retry attempts for failed requests (1-5)

maximum5
minimum1
spend_limits: optional object { enabled, rules }
enabled: optional boolean
rules: optional array of object { limit, limitType, window, 6 more }
limit: number
exclusiveMinimum
minimum0
limitType: "cost"
window: number
exclusiveMinimum
minimum0
id: optional string
minLength1
enabled: optional boolean
metadata: optional map[object { mode } or object { mode, values } ]
One of the following:
Mode object { mode }
mode: "partition"
object { mode, values }
mode: "filter"
values: array of string
model: optional object { mode, values }
mode: "filter"
values: array of string
provider: optional object { mode, values }
mode: "filter"
values: array of string
technique: optional "fixed" or "sliding"
One of the following:
"fixed"
"sliding"
store_id: optional string
stripe: optional object { authorization, usage_events }
authorization: string
usage_events: array of object { payload }
payload: string
workers_ai_billing_mode: optional "postpaid" or "unified"

Controls how Workers AI inference calls routed through this gateway are billed. ‘postpaid’ bills the account directly through Workers AI; ‘unified’ deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.

One of the following:
"postpaid"
"unified"
zdr: optional boolean
ReturnsExpand Collapse
result: object { id, cache_invalidate_on_update, cache_ttl, 25 more }
id: string

Unique identifier of the AI Gateway within the account.

maxLength64
minLength1
cache_invalidate_on_update: boolean
cache_ttl: number
minimum0
collect_logs: boolean
created_at: string
formatdate-time
modified_at: string
formatdate-time
rate_limiting_interval: number
minimum0
rate_limiting_limit: number
minimum0
authentication: optional boolean
byok_only: optional boolean

Requires customer-provided provider credentials and prevents fallback to Unified Billing.

dlp: optional object { action, enabled, profiles } or object { enabled, policies }
One of the following:
object { action, enabled, profiles }
action: "BLOCK" or "FLAG"
One of the following:
"BLOCK"
"FLAG"
enabled: boolean
profiles: array of string
object { enabled, policies }
enabled: boolean
policies: array of object { id, action, check, 2 more }
id: string
action: "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
check: array of "REQUEST" or "RESPONSE"
One of the following:
"REQUEST"
"RESPONSE"
enabled: boolean
profiles: array of string
guardrails: optional object { prompt, response }
prompt: object { P1, S1, S10, 11 more }
P1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S10: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S11: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S12: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S13: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S2: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S3: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S4: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S5: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S6: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S7: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S8: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S9: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
response: object { P1, S1, S10, 11 more }
P1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S1: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S10: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S11: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S12: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S13: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S2: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S3: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S4: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S5: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S6: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S7: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S8: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
S9: optional "FLAG" or "BLOCK"
One of the following:
"FLAG"
"BLOCK"
is_default: optional boolean
log_classification: optional boolean
log_management: optional number
maximum10000000
minimum10000
log_management_strategy: optional "STOP_INSERTING" or "DELETE_OLDEST"
One of the following:
"STOP_INSERTING"
"DELETE_OLDEST"
logpush: optional boolean
logpush_public_key: optional string
maxLength1024
minLength16
otel: optional array of object { headers, url, authorization, content_type }
headers: map[string]
url: string
formaturi
maxLength2048
authorization: optional string
maxLength256
content_type: optional "json" or "protobuf"
One of the following:
"json"
"protobuf"
rate_limiting_technique: optional "fixed" or "sliding"
One of the following:
"fixed"
"sliding"
retry_backoff: optional "constant" or "linear" or "exponential"

Backoff strategy for retry delays

One of the following:
"constant"
"linear"
"exponential"
retry_delay: optional number

Delay between retry attempts in milliseconds (0-60000)

maximum60000
minimum0
retry_max_attempts: optional number

Maximum number of retry attempts for failed requests (1-5)

maximum5
minimum1
spend_limits: optional object { enabled, rules }
enabled: optional boolean
rules: optional array of object { limit, limitType, window, 6 more }
limit: number
exclusiveMinimum
minimum0
limitType: "cost"
window: number
exclusiveMinimum
minimum0
id: optional string
minLength1
enabled: optional boolean
metadata: optional map[object { mode } or object { mode, values } ]
One of the following:
Mode object { mode }
mode: "partition"
object { mode, values }
mode: "filter"
values: array of string
model: optional object { mode, values }
mode: "filter"
values: array of string
provider: optional object { mode, values }
mode: "filter"
values: array of string
technique: optional "fixed" or "sliding"
One of the following:
"fixed"
"sliding"
store_id: optional string
stripe: optional object { authorization, usage_events }
authorization: string
usage_events: array of object { payload }
payload: string
workers_ai_billing_mode: optional "postpaid" or "unified"

Controls how Workers AI inference calls routed through this gateway are billed. ‘postpaid’ bills the account directly through Workers AI; ‘unified’ deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.

One of the following:
"postpaid"
"unified"
zdr: optional boolean
success: boolean

Update a gateway

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai-gateway/gateways/$ID \
    -X PUT \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "cache_invalidate_on_update": true,
          "cache_ttl": 0,
          "collect_logs": true,
          "rate_limiting_interval": 0,
          "rate_limiting_limit": 0
        }'
{
  "result": {
    "id": "my-gateway",
    "cache_invalidate_on_update": true,
    "cache_ttl": 0,
    "collect_logs": true,
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "rate_limiting_interval": 0,
    "rate_limiting_limit": 0,
    "authentication": true,
    "byok_only": true,
    "dlp": {
      "action": "BLOCK",
      "enabled": true,
      "profiles": [
        "string"
      ]
    },
    "guardrails": {
      "prompt": {
        "P1": "FLAG",
        "S1": "FLAG",
        "S10": "FLAG",
        "S11": "FLAG",
        "S12": "FLAG",
        "S13": "FLAG",
        "S2": "FLAG",
        "S3": "FLAG",
        "S4": "FLAG",
        "S5": "FLAG",
        "S6": "FLAG",
        "S7": "FLAG",
        "S8": "FLAG",
        "S9": "FLAG"
      },
      "response": {
        "P1": "FLAG",
        "S1": "FLAG",
        "S10": "FLAG",
        "S11": "FLAG",
        "S12": "FLAG",
        "S13": "FLAG",
        "S2": "FLAG",
        "S3": "FLAG",
        "S4": "FLAG",
        "S5": "FLAG",
        "S6": "FLAG",
        "S7": "FLAG",
        "S8": "FLAG",
        "S9": "FLAG"
      }
    },
    "is_default": true,
    "log_classification": true,
    "log_management": 10000,
    "log_management_strategy": "STOP_INSERTING",
    "logpush": true,
    "logpush_public_key": "xxxxxxxxxxxxxxxx",
    "otel": [
      {
        "headers": {
          "foo": "string"
        },
        "url": "https://example.com",
        "authorization": "authorization",
        "content_type": "json"
      }
    ],
    "rate_limiting_technique": "fixed",
    "retry_backoff": "constant",
    "retry_delay": 0,
    "retry_max_attempts": 1,
    "spend_limits": {
      "enabled": true,
      "rules": [
        {
          "limit": 1,
          "limitType": "cost",
          "window": 1,
          "id": "x",
          "enabled": true,
          "metadata": {
            "foo": {
              "mode": "partition"
            }
          },
          "model": {
            "mode": "filter",
            "values": [
              "string"
            ]
          },
          "provider": {
            "mode": "filter",
            "values": [
              "string"
            ]
          },
          "technique": "fixed"
        }
      ]
    },
    "store_id": "store_id",
    "stripe": {
      "authorization": "authorization",
      "usage_events": [
        {
          "payload": "payload"
        }
      ]
    },
    "workers_ai_billing_mode": "postpaid",
    "zdr": true
  },
  "success": true
}
Returns Examples
{
  "result": {
    "id": "my-gateway",
    "cache_invalidate_on_update": true,
    "cache_ttl": 0,
    "collect_logs": true,
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "rate_limiting_interval": 0,
    "rate_limiting_limit": 0,
    "authentication": true,
    "byok_only": true,
    "dlp": {
      "action": "BLOCK",
      "enabled": true,
      "profiles": [
        "string"
      ]
    },
    "guardrails": {
      "prompt": {
        "P1": "FLAG",
        "S1": "FLAG",
        "S10": "FLAG",
        "S11": "FLAG",
        "S12": "FLAG",
        "S13": "FLAG",
        "S2": "FLAG",
        "S3": "FLAG",
        "S4": "FLAG",
        "S5": "FLAG",
        "S6": "FLAG",
        "S7": "FLAG",
        "S8": "FLAG",
        "S9": "FLAG"
      },
      "response": {
        "P1": "FLAG",
        "S1": "FLAG",
        "S10": "FLAG",
        "S11": "FLAG",
        "S12": "FLAG",
        "S13": "FLAG",
        "S2": "FLAG",
        "S3": "FLAG",
        "S4": "FLAG",
        "S5": "FLAG",
        "S6": "FLAG",
        "S7": "FLAG",
        "S8": "FLAG",
        "S9": "FLAG"
      }
    },
    "is_default": true,
    "log_classification": true,
    "log_management": 10000,
    "log_management_strategy": "STOP_INSERTING",
    "logpush": true,
    "logpush_public_key": "xxxxxxxxxxxxxxxx",
    "otel": [
      {
        "headers": {
          "foo": "string"
        },
        "url": "https://example.com",
        "authorization": "authorization",
        "content_type": "json"
      }
    ],
    "rate_limiting_technique": "fixed",
    "retry_backoff": "constant",
    "retry_delay": 0,
    "retry_max_attempts": 1,
    "spend_limits": {
      "enabled": true,
      "rules": [
        {
          "limit": 1,
          "limitType": "cost",
          "window": 1,
          "id": "x",
          "enabled": true,
          "metadata": {
            "foo": {
              "mode": "partition"
            }
          },
          "model": {
            "mode": "filter",
            "values": [
              "string"
            ]
          },
          "provider": {
            "mode": "filter",
            "values": [
              "string"
            ]
          },
          "technique": "fixed"
        }
      ]
    },
    "store_id": "store_id",
    "stripe": {
      "authorization": "authorization",
      "usage_events": [
        {
          "payload": "payload"
        }
      ]
    },
    "workers_ai_billing_mode": "postpaid",
    "zdr": true
  },
  "success": true
}