## Create a new AI Gateway Dynamic Route. `client.AIGateway.DynamicRouting.New(ctx, gatewayID, params) (*DynamicRoutingNewResponse, error)` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes` Create a new AI Gateway Dynamic Route. ### Parameters - `gatewayID string` - `params DynamicRoutingNewParams` - `AccountID param.Field[string]` Path param - `Elements param.Field[[]DynamicRoutingNewParamsElement]` Body param - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewParamsElementsObjectOutputs` - `Next DynamicRoutingNewParamsElementsObjectOutputsNext` - `ElementID string` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypeStart DynamicRoutingNewParamsElementsObjectType = "start"` - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewParamsElementsObjectOutputs` - `False DynamicRoutingNewParamsElementsObjectOutputsFalse` - `ElementID string` - `True DynamicRoutingNewParamsElementsObjectOutputsTrue` - `ElementID string` - `Properties DynamicRoutingNewParamsElementsObjectProperties` - `Conditions unknown` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypeConditional DynamicRoutingNewParamsElementsObjectType = "conditional"` - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs map[string, DynamicRoutingNewParamsElementsObjectOutputs]` - `ElementID string` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypePercentage DynamicRoutingNewParamsElementsObjectType = "percentage"` - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewParamsElementsObjectOutputs` - `Fallback DynamicRoutingNewParamsElementsObjectOutputsFallback` - `ElementID string` - `Success DynamicRoutingNewParamsElementsObjectOutputsSuccess` - `ElementID string` - `Properties DynamicRoutingNewParamsElementsObjectProperties` - `Key string` - `Limit float64` - `LimitType DynamicRoutingNewParamsElementsObjectPropertiesLimitType` - `const DynamicRoutingNewParamsElementsObjectPropertiesLimitTypeCount DynamicRoutingNewParamsElementsObjectPropertiesLimitType = "count"` - `const DynamicRoutingNewParamsElementsObjectPropertiesLimitTypeCost DynamicRoutingNewParamsElementsObjectPropertiesLimitType = "cost"` - `Window float64` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypeRate DynamicRoutingNewParamsElementsObjectType = "rate"` - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewParamsElementsObjectOutputs` - `Fallback DynamicRoutingNewParamsElementsObjectOutputsFallback` - `ElementID string` - `Success DynamicRoutingNewParamsElementsObjectOutputsSuccess` - `ElementID string` - `Properties DynamicRoutingNewParamsElementsObjectProperties` - `Model string` - `Provider string` - `Retries float64` - `Timeout float64` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypeModel DynamicRoutingNewParamsElementsObjectType = "model"` - `type DynamicRoutingNewParamsElementsObject struct{…}` - `ID string` - `Outputs map[string, DynamicRoutingNewParamsElementsObjectOutputs]` - `ElementID string` - `Type DynamicRoutingNewParamsElementsObjectType` - `const DynamicRoutingNewParamsElementsObjectTypeEnd DynamicRoutingNewParamsElementsObjectType = "end"` - `Name param.Field[string]` Body param ### Returns - `type DynamicRoutingNewResponse struct{…}` - `ID string` - `CreatedAt Time` - `Deployment DynamicRoutingNewResponseDeployment` - `CreatedAt string` - `DeploymentID string` - `VersionID string` - `Elements []DynamicRoutingNewResponseElement` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewResponseElementsObjectOutputs` - `Next DynamicRoutingNewResponseElementsObjectOutputsNext` - `ElementID string` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypeStart DynamicRoutingNewResponseElementsObjectType = "start"` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewResponseElementsObjectOutputs` - `False DynamicRoutingNewResponseElementsObjectOutputsFalse` - `ElementID string` - `True DynamicRoutingNewResponseElementsObjectOutputsTrue` - `ElementID string` - `Properties DynamicRoutingNewResponseElementsObjectProperties` - `Conditions unknown` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypeConditional DynamicRoutingNewResponseElementsObjectType = "conditional"` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs map[string, DynamicRoutingNewResponseElementsObjectOutput]` - `ElementID string` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypePercentage DynamicRoutingNewResponseElementsObjectType = "percentage"` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewResponseElementsObjectOutputs` - `Fallback DynamicRoutingNewResponseElementsObjectOutputsFallback` - `ElementID string` - `Success DynamicRoutingNewResponseElementsObjectOutputsSuccess` - `ElementID string` - `Properties DynamicRoutingNewResponseElementsObjectProperties` - `Key string` - `Limit float64` - `LimitType DynamicRoutingNewResponseElementsObjectPropertiesLimitType` - `const DynamicRoutingNewResponseElementsObjectPropertiesLimitTypeCount DynamicRoutingNewResponseElementsObjectPropertiesLimitType = "count"` - `const DynamicRoutingNewResponseElementsObjectPropertiesLimitTypeCost DynamicRoutingNewResponseElementsObjectPropertiesLimitType = "cost"` - `Window float64` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypeRate DynamicRoutingNewResponseElementsObjectType = "rate"` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs DynamicRoutingNewResponseElementsObjectOutputs` - `Fallback DynamicRoutingNewResponseElementsObjectOutputsFallback` - `ElementID string` - `Success DynamicRoutingNewResponseElementsObjectOutputsSuccess` - `ElementID string` - `Properties DynamicRoutingNewResponseElementsObjectProperties` - `Model string` - `Provider string` - `Retries float64` - `Timeout float64` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypeModel DynamicRoutingNewResponseElementsObjectType = "model"` - `type DynamicRoutingNewResponseElementsObject struct{…}` - `ID string` - `Outputs map[string, DynamicRoutingNewResponseElementsObjectOutput]` - `ElementID string` - `Type DynamicRoutingNewResponseElementsObjectType` - `const DynamicRoutingNewResponseElementsObjectTypeEnd DynamicRoutingNewResponseElementsObjectType = "end"` - `GatewayID string` - `ModifiedAt Time` - `Name string` - `Version DynamicRoutingNewResponseVersion` - `Active DynamicRoutingNewResponseVersionActive` - `const DynamicRoutingNewResponseVersionActiveTrue DynamicRoutingNewResponseVersionActive = "true"` - `const DynamicRoutingNewResponseVersionActiveFalse DynamicRoutingNewResponseVersionActive = "false"` - `CreatedAt string` - `Data string` - `VersionID string` ### 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"), ) dynamicRouting, err := client.AIGateway.DynamicRouting.New( context.TODO(), "54442216", ai_gateway.DynamicRoutingNewParams{ AccountID: cloudflare.F("0d37909e38d3e99c29fa2cd343ac421a"), Elements: cloudflare.F([]ai_gateway.DynamicRoutingNewParamsElementUnion{ai_gateway.DynamicRoutingNewParamsElementsObject{ ID: cloudflare.F("id"), Outputs: cloudflare.F(ai_gateway.DynamicRoutingNewParamsElementsObjectOutputs{ Next: cloudflare.F(ai_gateway.DynamicRoutingNewParamsElementsObjectOutputsNext{ ElementID: cloudflare.F("elementId"), }), }), Type: cloudflare.F(ai_gateway.DynamicRoutingNewParamsElementsObjectTypeStart), }}), Name: cloudflare.F("name"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dynamicRouting.ID) } ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "deployment": { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" }, "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version": { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } }, "success": true } ```