Skip to content
Start here

Update a Gateway

client.AIGateway.Update(ctx, id, params) (*AIGatewayUpdateResponse, error)
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
AccountID param.Field[string]

Path param

CacheInvalidateOnUpdate param.Field[bool]

Body param

CacheTTL param.Field[int64]

Body param

minimum0
CollectLogs param.Field[bool]

Body param

RateLimitingInterval param.Field[int64]

Body param

minimum0
RateLimitingLimit param.Field[int64]

Body param

minimum0
Authentication param.Field[bool]optional

Body param

DLP param.Field[AIGatewayUpdateParamsDLP]optional

Body param

type AIGatewayUpdateParamsDLPObject struct{…}
Action AIGatewayUpdateParamsDLPObjectAction
One of the following:
const AIGatewayUpdateParamsDLPObjectActionBlock AIGatewayUpdateParamsDLPObjectAction = "BLOCK"
const AIGatewayUpdateParamsDLPObjectActionFlag AIGatewayUpdateParamsDLPObjectAction = "FLAG"
Enabled bool
Profiles []string
type AIGatewayUpdateParamsDLPObject struct{…}
Enabled bool
Policies []AIGatewayUpdateParamsDLPObjectPolicy
ID string
Action AIGatewayUpdateParamsDLPObjectPoliciesAction
One of the following:
const AIGatewayUpdateParamsDLPObjectPoliciesActionFlag AIGatewayUpdateParamsDLPObjectPoliciesAction = "FLAG"
const AIGatewayUpdateParamsDLPObjectPoliciesActionBlock AIGatewayUpdateParamsDLPObjectPoliciesAction = "BLOCK"
Check []AIGatewayUpdateParamsDLPObjectPoliciesCheck
One of the following:
const AIGatewayUpdateParamsDLPObjectPoliciesCheckRequest AIGatewayUpdateParamsDLPObjectPoliciesCheck = "REQUEST"
const AIGatewayUpdateParamsDLPObjectPoliciesCheckResponse AIGatewayUpdateParamsDLPObjectPoliciesCheck = "RESPONSE"
Enabled bool
Profiles []string
LogManagement param.Field[int64]optional

Body param

maximum10000000
minimum10000
LogManagementStrategy param.Field[AIGatewayUpdateParamsLogManagementStrategy]optional

Body param

const AIGatewayUpdateParamsLogManagementStrategyStopInserting AIGatewayUpdateParamsLogManagementStrategy = "STOP_INSERTING"
const AIGatewayUpdateParamsLogManagementStrategyDeleteOldest AIGatewayUpdateParamsLogManagementStrategy = "DELETE_OLDEST"
Logpush param.Field[bool]optional

Body param

LogpushPublicKey param.Field[string]optional

Body param

maxLength1024
minLength16
Otel param.Field[[]AIGatewayUpdateParamsOtel]optional

Body param

Authorization string
Headers map[string, string]
URL string
ContentType AIGatewayUpdateParamsOtelContentTypeoptional
One of the following:
const AIGatewayUpdateParamsOtelContentTypeJson AIGatewayUpdateParamsOtelContentType = "json"
const AIGatewayUpdateParamsOtelContentTypeProtobuf AIGatewayUpdateParamsOtelContentType = "protobuf"
RateLimitingTechnique param.Field[AIGatewayUpdateParamsRateLimitingTechnique]optional

Body param

const AIGatewayUpdateParamsRateLimitingTechniqueFixed AIGatewayUpdateParamsRateLimitingTechnique = "fixed"
const AIGatewayUpdateParamsRateLimitingTechniqueSliding AIGatewayUpdateParamsRateLimitingTechnique = "sliding"
RetryBackoff param.Field[AIGatewayUpdateParamsRetryBackoff]optional

Body param: Backoff strategy for retry delays

const AIGatewayUpdateParamsRetryBackoffConstant AIGatewayUpdateParamsRetryBackoff = "constant"
const AIGatewayUpdateParamsRetryBackoffLinear AIGatewayUpdateParamsRetryBackoff = "linear"
const AIGatewayUpdateParamsRetryBackoffExponential AIGatewayUpdateParamsRetryBackoff = "exponential"
RetryDelay param.Field[int64]optional

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

maximum5000
minimum0
RetryMaxAttempts param.Field[int64]optional

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

maximum5
minimum1
StoreID param.Field[string]optional

Body param

Stripe param.Field[AIGatewayUpdateParamsStripe]optional

Body param

Authorization string
UsageEvents []AIGatewayUpdateParamsStripeUsageEvent
Payload string
WorkersAIBillingMode param.Field[AIGatewayUpdateParamsWorkersAIBillingMode]optional

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

const AIGatewayUpdateParamsWorkersAIBillingModePostpaid AIGatewayUpdateParamsWorkersAIBillingMode = "postpaid"
Zdr param.Field[bool]optional

Body param

ReturnsExpand Collapse
type AIGatewayUpdateResponse struct{…}
ID string

gateway id

maxLength64
minLength1
CacheInvalidateOnUpdate bool
CacheTTL int64
minimum0
CollectLogs bool
CreatedAt Time
formatdate-time
ModifiedAt Time
formatdate-time
RateLimitingInterval int64
minimum0
RateLimitingLimit int64
minimum0
Authentication booloptional
DLP AIGatewayUpdateResponseDLPoptional
One of the following:
type AIGatewayUpdateResponseDLPObject struct{…}
Action AIGatewayUpdateResponseDLPObjectAction
One of the following:
const AIGatewayUpdateResponseDLPObjectActionBlock AIGatewayUpdateResponseDLPObjectAction = "BLOCK"
const AIGatewayUpdateResponseDLPObjectActionFlag AIGatewayUpdateResponseDLPObjectAction = "FLAG"
Enabled bool
Profiles []string
type AIGatewayUpdateResponseDLPObject struct{…}
Enabled bool
Policies []AIGatewayUpdateResponseDLPObjectPolicy
ID string
Action AIGatewayUpdateResponseDLPObjectPoliciesAction
One of the following:
const AIGatewayUpdateResponseDLPObjectPoliciesActionFlag AIGatewayUpdateResponseDLPObjectPoliciesAction = "FLAG"
const AIGatewayUpdateResponseDLPObjectPoliciesActionBlock AIGatewayUpdateResponseDLPObjectPoliciesAction = "BLOCK"
Check []AIGatewayUpdateResponseDLPObjectPoliciesCheck
One of the following:
const AIGatewayUpdateResponseDLPObjectPoliciesCheckRequest AIGatewayUpdateResponseDLPObjectPoliciesCheck = "REQUEST"
const AIGatewayUpdateResponseDLPObjectPoliciesCheckResponse AIGatewayUpdateResponseDLPObjectPoliciesCheck = "RESPONSE"
Enabled bool
Profiles []string
IsDefault booloptional
LogManagement int64optional
maximum10000000
minimum10000
LogManagementStrategy AIGatewayUpdateResponseLogManagementStrategyoptional
One of the following:
const AIGatewayUpdateResponseLogManagementStrategyStopInserting AIGatewayUpdateResponseLogManagementStrategy = "STOP_INSERTING"
const AIGatewayUpdateResponseLogManagementStrategyDeleteOldest AIGatewayUpdateResponseLogManagementStrategy = "DELETE_OLDEST"
Logpush booloptional
LogpushPublicKey stringoptional
maxLength1024
minLength16
Otel []AIGatewayUpdateResponseOteloptional
Authorization string
Headers map[string, string]
URL string
ContentType AIGatewayUpdateResponseOtelContentTypeoptional
One of the following:
const AIGatewayUpdateResponseOtelContentTypeJson AIGatewayUpdateResponseOtelContentType = "json"
const AIGatewayUpdateResponseOtelContentTypeProtobuf AIGatewayUpdateResponseOtelContentType = "protobuf"
RateLimitingTechnique AIGatewayUpdateResponseRateLimitingTechniqueoptional
One of the following:
const AIGatewayUpdateResponseRateLimitingTechniqueFixed AIGatewayUpdateResponseRateLimitingTechnique = "fixed"
const AIGatewayUpdateResponseRateLimitingTechniqueSliding AIGatewayUpdateResponseRateLimitingTechnique = "sliding"
RetryBackoff AIGatewayUpdateResponseRetryBackoffoptional

Backoff strategy for retry delays

One of the following:
const AIGatewayUpdateResponseRetryBackoffConstant AIGatewayUpdateResponseRetryBackoff = "constant"
const AIGatewayUpdateResponseRetryBackoffLinear AIGatewayUpdateResponseRetryBackoff = "linear"
const AIGatewayUpdateResponseRetryBackoffExponential AIGatewayUpdateResponseRetryBackoff = "exponential"
RetryDelay int64optional

Delay between retry attempts in milliseconds (0-5000)

maximum5000
minimum0
RetryMaxAttempts int64optional

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

maximum5
minimum1
StoreID stringoptional
Stripe AIGatewayUpdateResponseStripeoptional
Authorization string
UsageEvents []AIGatewayUpdateResponseStripeUsageEvent
Payload string
WorkersAIBillingMode AIGatewayUpdateResponseWorkersAIBillingModeoptional

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

Zdr booloptional

Update a Gateway

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_gateway"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  aiGateway, err := client.AIGateway.Update(
    context.TODO(),
    "my-gateway",
    ai_gateway.AIGatewayUpdateParams{
      AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
      CacheInvalidateOnUpdate: cloudflare.F(true),
      CacheTTL: cloudflare.F(int64(0)),
      CollectLogs: cloudflare.F(true),
      RateLimitingInterval: cloudflare.F(int64(0)),
      RateLimitingLimit: cloudflare.F(int64(0)),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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
}