Skip to content
Start here

Update a Gateway

client.aiGateway.update(stringid, AIGatewayUpdateParams { account_id, cache_invalidate_on_update, cache_ttl, 18 more } params, RequestOptionsoptions?): AIGatewayUpdateResponse { id, cache_invalidate_on_update, cache_ttl, 21 more }
PUT/accounts/{account_id}/ai-gateway/gateways/{id}

Updates an existing AI Gateway dataset.

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
ParametersExpand Collapse
id: string

gateway id

maxLength64
minLength1
params: AIGatewayUpdateParams { account_id, cache_invalidate_on_update, cache_ttl, 18 more }
account_id: string

Path param

cache_invalidate_on_update: boolean

Body param

cache_ttl: number | null

Body param

minimum0
collect_logs: boolean

Body param

rate_limiting_interval: number | null

Body param

minimum0
rate_limiting_limit: number | null

Body param

minimum0
authentication?: boolean

Body param

dlp?: UnionMember0 { action, enabled, profiles } | UnionMember1 { enabled, policies }

Body param

One of the following:
UnionMember0 { action, enabled, profiles }
action: "BLOCK" | "FLAG"
One of the following:
"BLOCK"
"FLAG"
enabled: boolean
profiles: Array<string>
UnionMember1 { enabled, policies }
enabled: boolean
policies: Array<Policy>
id: string
action: "FLAG" | "BLOCK"
One of the following:
"FLAG"
"BLOCK"
check: Array<"REQUEST" | "RESPONSE">
One of the following:
"REQUEST"
"RESPONSE"
enabled: boolean
profiles: Array<string>
log_management?: number | null

Body param

maximum10000000
minimum10000
log_management_strategy?: "STOP_INSERTING" | "DELETE_OLDEST" | null

Body param

One of the following:
"STOP_INSERTING"
"DELETE_OLDEST"
logpush?: boolean

Body param

logpush_public_key?: string | null

Body param

maxLength1024
minLength16
otel?: Array<Otel> | null

Body param

authorization: string
headers: Record<string, string>
url: string
content_type?: "json" | "protobuf"
One of the following:
"json"
"protobuf"
rate_limiting_technique?: "fixed" | "sliding" | null

Body param

One of the following:
"fixed"
"sliding"
retry_backoff?: "constant" | "linear" | "exponential" | null

Body param: Backoff strategy for retry delays

One of the following:
"constant"
"linear"
"exponential"
retry_delay?: number | null

Body param: Delay between retry attempts in milliseconds (0-5000)

maximum5000
minimum0
retry_max_attempts?: number | null

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

maximum5
minimum1
store_id?: string | null

Body param

stripe?: Stripe | null

Body param

authorization: string
usage_events: Array<UsageEvent>
payload: string
workers_ai_billing_mode?: "postpaid"

Body param: Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.

zdr?: boolean

Body param

ReturnsExpand Collapse
AIGatewayUpdateResponse { id, cache_invalidate_on_update, cache_ttl, 21 more }
id: string

gateway id

maxLength64
minLength1
cache_invalidate_on_update: boolean
cache_ttl: number | null
minimum0
collect_logs: boolean
created_at: string
formatdate-time
modified_at: string
formatdate-time
rate_limiting_interval: number | null
minimum0
rate_limiting_limit: number | null
minimum0
authentication?: boolean
dlp?: UnionMember0 { action, enabled, profiles } | UnionMember1 { enabled, policies }
One of the following:
UnionMember0 { action, enabled, profiles }
action: "BLOCK" | "FLAG"
One of the following:
"BLOCK"
"FLAG"
enabled: boolean
profiles: Array<string>
UnionMember1 { enabled, policies }
enabled: boolean
policies: Array<Policy>
id: string
action: "FLAG" | "BLOCK"
One of the following:
"FLAG"
"BLOCK"
check: Array<"REQUEST" | "RESPONSE">
One of the following:
"REQUEST"
"RESPONSE"
enabled: boolean
profiles: Array<string>
is_default?: boolean
log_management?: number | null
maximum10000000
minimum10000
log_management_strategy?: "STOP_INSERTING" | "DELETE_OLDEST" | null
One of the following:
"STOP_INSERTING"
"DELETE_OLDEST"
logpush?: boolean
logpush_public_key?: string | null
maxLength1024
minLength16
otel?: Array<Otel> | null
authorization: string
headers: Record<string, string>
url: string
content_type?: "json" | "protobuf"
One of the following:
"json"
"protobuf"
rate_limiting_technique?: "fixed" | "sliding" | null
One of the following:
"fixed"
"sliding"
retry_backoff?: "constant" | "linear" | "exponential" | null

Backoff strategy for retry delays

One of the following:
"constant"
"linear"
"exponential"
retry_delay?: number | null

Delay between retry attempts in milliseconds (0-5000)

maximum5000
minimum0
retry_max_attempts?: number | null

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

maximum5
minimum1
store_id?: string | null
stripe?: Stripe | null
authorization: string
usage_events: Array<UsageEvent>
payload: string
workers_ai_billing_mode?: "postpaid"

Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.

zdr?: boolean

Update a Gateway

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const aiGateway = await client.aiGateway.update('my-gateway', {
  account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0',
  cache_invalidate_on_update: true,
  cache_ttl: 0,
  collect_logs: true,
  rate_limiting_interval: 0,
  rate_limiting_limit: 0,
});

console.log(aiGateway.id);
{
  "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,
    "dlp": {
      "action": "BLOCK",
      "enabled": true,
      "profiles": [
        "string"
      ]
    },
    "is_default": true,
    "log_management": 10000,
    "log_management_strategy": "STOP_INSERTING",
    "logpush": true,
    "logpush_public_key": "xxxxxxxxxxxxxxxx",
    "otel": [
      {
        "authorization": "authorization",
        "headers": {
          "foo": "string"
        },
        "url": "url",
        "content_type": "json"
      }
    ],
    "rate_limiting_technique": "fixed",
    "retry_backoff": "constant",
    "retry_delay": 0,
    "retry_max_attempts": 1,
    "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,
    "dlp": {
      "action": "BLOCK",
      "enabled": true,
      "profiles": [
        "string"
      ]
    },
    "is_default": true,
    "log_management": 10000,
    "log_management_strategy": "STOP_INSERTING",
    "logpush": true,
    "logpush_public_key": "xxxxxxxxxxxxxxxx",
    "otel": [
      {
        "authorization": "authorization",
        "headers": {
          "foo": "string"
        },
        "url": "url",
        "content_type": "json"
      }
    ],
    "rate_limiting_technique": "fixed",
    "retry_backoff": "constant",
    "retry_delay": 0,
    "retry_max_attempts": 1,
    "store_id": "store_id",
    "stripe": {
      "authorization": "authorization",
      "usage_events": [
        {
          "payload": "payload"
        }
      ]
    },
    "workers_ai_billing_mode": "postpaid",
    "zdr": true
  },
  "success": true
}