## Create a new Gateway `client.AIGateway.New(ctx, params) (*AIGatewayNewResponse, error)` **post** `/accounts/{account_id}/ai-gateway/gateways` Creates a new AI Gateway. ### Parameters - `params AIGatewayNewParams` - `AccountID param.Field[string]` Path param - `ID param.Field[string]` Body param: gateway id - `CacheInvalidateOnUpdate param.Field[bool]` Body param - `CacheTTL param.Field[int64]` Body param - `CollectLogs param.Field[bool]` Body param - `RateLimitingInterval param.Field[int64]` Body param - `RateLimitingLimit param.Field[int64]` Body param - `Authentication param.Field[bool]` Body param - `LogManagement param.Field[int64]` Body param - `LogManagementStrategy param.Field[AIGatewayNewParamsLogManagementStrategy]` Body param - `const AIGatewayNewParamsLogManagementStrategyStopInserting AIGatewayNewParamsLogManagementStrategy = "STOP_INSERTING"` - `const AIGatewayNewParamsLogManagementStrategyDeleteOldest AIGatewayNewParamsLogManagementStrategy = "DELETE_OLDEST"` - `Logpush param.Field[bool]` Body param - `LogpushPublicKey param.Field[string]` Body param - `RateLimitingTechnique param.Field[AIGatewayNewParamsRateLimitingTechnique]` Body param - `const AIGatewayNewParamsRateLimitingTechniqueFixed AIGatewayNewParamsRateLimitingTechnique = "fixed"` - `const AIGatewayNewParamsRateLimitingTechniqueSliding AIGatewayNewParamsRateLimitingTechnique = "sliding"` - `RetryBackoff param.Field[AIGatewayNewParamsRetryBackoff]` Body param: Backoff strategy for retry delays - `const AIGatewayNewParamsRetryBackoffConstant AIGatewayNewParamsRetryBackoff = "constant"` - `const AIGatewayNewParamsRetryBackoffLinear AIGatewayNewParamsRetryBackoff = "linear"` - `const AIGatewayNewParamsRetryBackoffExponential AIGatewayNewParamsRetryBackoff = "exponential"` - `RetryDelay param.Field[int64]` Body param: Delay between retry attempts in milliseconds (0-5000) - `RetryMaxAttempts param.Field[int64]` Body param: Maximum number of retry attempts for failed requests (1-5) - `WorkersAIBillingMode param.Field[AIGatewayNewParamsWorkersAIBillingMode]` Body param: Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `const AIGatewayNewParamsWorkersAIBillingModePostpaid AIGatewayNewParamsWorkersAIBillingMode = "postpaid"` - `Zdr param.Field[bool]` Body param ### Returns - `type AIGatewayNewResponse struct{…}` - `ID string` gateway id - `CacheInvalidateOnUpdate bool` - `CacheTTL int64` - `CollectLogs bool` - `CreatedAt Time` - `ModifiedAt Time` - `RateLimitingInterval int64` - `RateLimitingLimit int64` - `Authentication bool` - `DLP AIGatewayNewResponseDLP` - `type AIGatewayNewResponseDLPObject struct{…}` - `Action AIGatewayNewResponseDLPObjectAction` - `const AIGatewayNewResponseDLPObjectActionBlock AIGatewayNewResponseDLPObjectAction = "BLOCK"` - `const AIGatewayNewResponseDLPObjectActionFlag AIGatewayNewResponseDLPObjectAction = "FLAG"` - `Enabled bool` - `Profiles []string` - `type AIGatewayNewResponseDLPObject struct{…}` - `Enabled bool` - `Policies []AIGatewayNewResponseDLPObjectPolicy` - `ID string` - `Action AIGatewayNewResponseDLPObjectPoliciesAction` - `const AIGatewayNewResponseDLPObjectPoliciesActionFlag AIGatewayNewResponseDLPObjectPoliciesAction = "FLAG"` - `const AIGatewayNewResponseDLPObjectPoliciesActionBlock AIGatewayNewResponseDLPObjectPoliciesAction = "BLOCK"` - `Check []AIGatewayNewResponseDLPObjectPoliciesCheck` - `const AIGatewayNewResponseDLPObjectPoliciesCheckRequest AIGatewayNewResponseDLPObjectPoliciesCheck = "REQUEST"` - `const AIGatewayNewResponseDLPObjectPoliciesCheckResponse AIGatewayNewResponseDLPObjectPoliciesCheck = "RESPONSE"` - `Enabled bool` - `Profiles []string` - `Guardrails AIGatewayNewResponseGuardrails` - `Prompt AIGatewayNewResponseGuardrailsPrompt` - `P1 AIGatewayNewResponseGuardrailsPromptP1` - `const AIGatewayNewResponseGuardrailsPromptP1Flag AIGatewayNewResponseGuardrailsPromptP1 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptP1Block AIGatewayNewResponseGuardrailsPromptP1 = "BLOCK"` - `S1 AIGatewayNewResponseGuardrailsPromptS1` - `const AIGatewayNewResponseGuardrailsPromptS1Flag AIGatewayNewResponseGuardrailsPromptS1 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS1Block AIGatewayNewResponseGuardrailsPromptS1 = "BLOCK"` - `S10 AIGatewayNewResponseGuardrailsPromptS10` - `const AIGatewayNewResponseGuardrailsPromptS10Flag AIGatewayNewResponseGuardrailsPromptS10 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS10Block AIGatewayNewResponseGuardrailsPromptS10 = "BLOCK"` - `S11 AIGatewayNewResponseGuardrailsPromptS11` - `const AIGatewayNewResponseGuardrailsPromptS11Flag AIGatewayNewResponseGuardrailsPromptS11 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS11Block AIGatewayNewResponseGuardrailsPromptS11 = "BLOCK"` - `S12 AIGatewayNewResponseGuardrailsPromptS12` - `const AIGatewayNewResponseGuardrailsPromptS12Flag AIGatewayNewResponseGuardrailsPromptS12 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS12Block AIGatewayNewResponseGuardrailsPromptS12 = "BLOCK"` - `S13 AIGatewayNewResponseGuardrailsPromptS13` - `const AIGatewayNewResponseGuardrailsPromptS13Flag AIGatewayNewResponseGuardrailsPromptS13 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS13Block AIGatewayNewResponseGuardrailsPromptS13 = "BLOCK"` - `S2 AIGatewayNewResponseGuardrailsPromptS2` - `const AIGatewayNewResponseGuardrailsPromptS2Flag AIGatewayNewResponseGuardrailsPromptS2 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS2Block AIGatewayNewResponseGuardrailsPromptS2 = "BLOCK"` - `S3 AIGatewayNewResponseGuardrailsPromptS3` - `const AIGatewayNewResponseGuardrailsPromptS3Flag AIGatewayNewResponseGuardrailsPromptS3 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS3Block AIGatewayNewResponseGuardrailsPromptS3 = "BLOCK"` - `S4 AIGatewayNewResponseGuardrailsPromptS4` - `const AIGatewayNewResponseGuardrailsPromptS4Flag AIGatewayNewResponseGuardrailsPromptS4 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS4Block AIGatewayNewResponseGuardrailsPromptS4 = "BLOCK"` - `S5 AIGatewayNewResponseGuardrailsPromptS5` - `const AIGatewayNewResponseGuardrailsPromptS5Flag AIGatewayNewResponseGuardrailsPromptS5 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS5Block AIGatewayNewResponseGuardrailsPromptS5 = "BLOCK"` - `S6 AIGatewayNewResponseGuardrailsPromptS6` - `const AIGatewayNewResponseGuardrailsPromptS6Flag AIGatewayNewResponseGuardrailsPromptS6 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS6Block AIGatewayNewResponseGuardrailsPromptS6 = "BLOCK"` - `S7 AIGatewayNewResponseGuardrailsPromptS7` - `const AIGatewayNewResponseGuardrailsPromptS7Flag AIGatewayNewResponseGuardrailsPromptS7 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS7Block AIGatewayNewResponseGuardrailsPromptS7 = "BLOCK"` - `S8 AIGatewayNewResponseGuardrailsPromptS8` - `const AIGatewayNewResponseGuardrailsPromptS8Flag AIGatewayNewResponseGuardrailsPromptS8 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS8Block AIGatewayNewResponseGuardrailsPromptS8 = "BLOCK"` - `S9 AIGatewayNewResponseGuardrailsPromptS9` - `const AIGatewayNewResponseGuardrailsPromptS9Flag AIGatewayNewResponseGuardrailsPromptS9 = "FLAG"` - `const AIGatewayNewResponseGuardrailsPromptS9Block AIGatewayNewResponseGuardrailsPromptS9 = "BLOCK"` - `Response AIGatewayNewResponseGuardrailsResponse` - `P1 AIGatewayNewResponseGuardrailsResponseP1` - `const AIGatewayNewResponseGuardrailsResponseP1Flag AIGatewayNewResponseGuardrailsResponseP1 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseP1Block AIGatewayNewResponseGuardrailsResponseP1 = "BLOCK"` - `S1 AIGatewayNewResponseGuardrailsResponseS1` - `const AIGatewayNewResponseGuardrailsResponseS1Flag AIGatewayNewResponseGuardrailsResponseS1 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS1Block AIGatewayNewResponseGuardrailsResponseS1 = "BLOCK"` - `S10 AIGatewayNewResponseGuardrailsResponseS10` - `const AIGatewayNewResponseGuardrailsResponseS10Flag AIGatewayNewResponseGuardrailsResponseS10 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS10Block AIGatewayNewResponseGuardrailsResponseS10 = "BLOCK"` - `S11 AIGatewayNewResponseGuardrailsResponseS11` - `const AIGatewayNewResponseGuardrailsResponseS11Flag AIGatewayNewResponseGuardrailsResponseS11 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS11Block AIGatewayNewResponseGuardrailsResponseS11 = "BLOCK"` - `S12 AIGatewayNewResponseGuardrailsResponseS12` - `const AIGatewayNewResponseGuardrailsResponseS12Flag AIGatewayNewResponseGuardrailsResponseS12 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS12Block AIGatewayNewResponseGuardrailsResponseS12 = "BLOCK"` - `S13 AIGatewayNewResponseGuardrailsResponseS13` - `const AIGatewayNewResponseGuardrailsResponseS13Flag AIGatewayNewResponseGuardrailsResponseS13 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS13Block AIGatewayNewResponseGuardrailsResponseS13 = "BLOCK"` - `S2 AIGatewayNewResponseGuardrailsResponseS2` - `const AIGatewayNewResponseGuardrailsResponseS2Flag AIGatewayNewResponseGuardrailsResponseS2 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS2Block AIGatewayNewResponseGuardrailsResponseS2 = "BLOCK"` - `S3 AIGatewayNewResponseGuardrailsResponseS3` - `const AIGatewayNewResponseGuardrailsResponseS3Flag AIGatewayNewResponseGuardrailsResponseS3 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS3Block AIGatewayNewResponseGuardrailsResponseS3 = "BLOCK"` - `S4 AIGatewayNewResponseGuardrailsResponseS4` - `const AIGatewayNewResponseGuardrailsResponseS4Flag AIGatewayNewResponseGuardrailsResponseS4 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS4Block AIGatewayNewResponseGuardrailsResponseS4 = "BLOCK"` - `S5 AIGatewayNewResponseGuardrailsResponseS5` - `const AIGatewayNewResponseGuardrailsResponseS5Flag AIGatewayNewResponseGuardrailsResponseS5 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS5Block AIGatewayNewResponseGuardrailsResponseS5 = "BLOCK"` - `S6 AIGatewayNewResponseGuardrailsResponseS6` - `const AIGatewayNewResponseGuardrailsResponseS6Flag AIGatewayNewResponseGuardrailsResponseS6 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS6Block AIGatewayNewResponseGuardrailsResponseS6 = "BLOCK"` - `S7 AIGatewayNewResponseGuardrailsResponseS7` - `const AIGatewayNewResponseGuardrailsResponseS7Flag AIGatewayNewResponseGuardrailsResponseS7 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS7Block AIGatewayNewResponseGuardrailsResponseS7 = "BLOCK"` - `S8 AIGatewayNewResponseGuardrailsResponseS8` - `const AIGatewayNewResponseGuardrailsResponseS8Flag AIGatewayNewResponseGuardrailsResponseS8 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS8Block AIGatewayNewResponseGuardrailsResponseS8 = "BLOCK"` - `S9 AIGatewayNewResponseGuardrailsResponseS9` - `const AIGatewayNewResponseGuardrailsResponseS9Flag AIGatewayNewResponseGuardrailsResponseS9 = "FLAG"` - `const AIGatewayNewResponseGuardrailsResponseS9Block AIGatewayNewResponseGuardrailsResponseS9 = "BLOCK"` - `IsDefault bool` - `LogManagement int64` - `LogManagementStrategy AIGatewayNewResponseLogManagementStrategy` - `const AIGatewayNewResponseLogManagementStrategyStopInserting AIGatewayNewResponseLogManagementStrategy = "STOP_INSERTING"` - `const AIGatewayNewResponseLogManagementStrategyDeleteOldest AIGatewayNewResponseLogManagementStrategy = "DELETE_OLDEST"` - `Logpush bool` - `LogpushPublicKey string` - `Otel []AIGatewayNewResponseOtel` - `Authorization string` - `Headers map[string, string]` - `URL string` - `ContentType AIGatewayNewResponseOtelContentType` - `const AIGatewayNewResponseOtelContentTypeJson AIGatewayNewResponseOtelContentType = "json"` - `const AIGatewayNewResponseOtelContentTypeProtobuf AIGatewayNewResponseOtelContentType = "protobuf"` - `RateLimitingTechnique AIGatewayNewResponseRateLimitingTechnique` - `const AIGatewayNewResponseRateLimitingTechniqueFixed AIGatewayNewResponseRateLimitingTechnique = "fixed"` - `const AIGatewayNewResponseRateLimitingTechniqueSliding AIGatewayNewResponseRateLimitingTechnique = "sliding"` - `RetryBackoff AIGatewayNewResponseRetryBackoff` Backoff strategy for retry delays - `const AIGatewayNewResponseRetryBackoffConstant AIGatewayNewResponseRetryBackoff = "constant"` - `const AIGatewayNewResponseRetryBackoffLinear AIGatewayNewResponseRetryBackoff = "linear"` - `const AIGatewayNewResponseRetryBackoffExponential AIGatewayNewResponseRetryBackoff = "exponential"` - `RetryDelay int64` Delay between retry attempts in milliseconds (0-5000) - `RetryMaxAttempts int64` Maximum number of retry attempts for failed requests (1-5) - `StoreID string` - `Stripe AIGatewayNewResponseStripe` - `Authorization string` - `UsageEvents []AIGatewayNewResponseStripeUsageEvent` - `Payload string` - `WorkersAIBillingMode AIGatewayNewResponseWorkersAIBillingMode` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `const AIGatewayNewResponseWorkersAIBillingModePostpaid AIGatewayNewResponseWorkersAIBillingMode = "postpaid"` - `Zdr bool` ### Example ```go 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.New(context.TODO(), ai_gateway.AIGatewayNewParams{ AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"), ID: cloudflare.F("my-gateway"), 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) } ``` #### Response ```json { "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" ] }, "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_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "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 } ```