Skip to content
Start here

Create a new AI Gateway Dynamic Route Version.

client.AIGateway.DynamicRouting.NewVersion(ctx, gatewayID, id, params) (*DynamicRoutingNewVersionResponse, error)
POST/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions

Create a new AI Gateway Dynamic Route Version.

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
gatewayID string
id string
params DynamicRoutingNewVersionParams
AccountID param.Field[string]

Path param

Elements param.Field[[]DynamicRoutingNewVersionParamsElement]

Body param

type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionParamsElementsObjectOutputs
Type DynamicRoutingNewVersionParamsElementsObjectType
type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionParamsElementsObjectOutputs
False DynamicRoutingNewVersionParamsElementsObjectOutputsFalse
ElementID string
True DynamicRoutingNewVersionParamsElementsObjectOutputsTrue
ElementID string
Properties DynamicRoutingNewVersionParamsElementsObjectProperties
Conditions unknownoptional
Type DynamicRoutingNewVersionParamsElementsObjectType
type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs map[string, DynamicRoutingNewVersionParamsElementsObjectOutputs]
ElementID string
Type DynamicRoutingNewVersionParamsElementsObjectType
type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionParamsElementsObjectOutputs
Fallback DynamicRoutingNewVersionParamsElementsObjectOutputsFallback
ElementID string
Success DynamicRoutingNewVersionParamsElementsObjectOutputsSuccess
ElementID string
Properties DynamicRoutingNewVersionParamsElementsObjectProperties
Key string
Limit float64
LimitType DynamicRoutingNewVersionParamsElementsObjectPropertiesLimitType
One of the following:
const DynamicRoutingNewVersionParamsElementsObjectPropertiesLimitTypeCount DynamicRoutingNewVersionParamsElementsObjectPropertiesLimitType = "count"
const DynamicRoutingNewVersionParamsElementsObjectPropertiesLimitTypeCost DynamicRoutingNewVersionParamsElementsObjectPropertiesLimitType = "cost"
Window float64
Type DynamicRoutingNewVersionParamsElementsObjectType
type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionParamsElementsObjectOutputs
Fallback DynamicRoutingNewVersionParamsElementsObjectOutputsFallback
ElementID string
Success DynamicRoutingNewVersionParamsElementsObjectOutputsSuccess
ElementID string
Properties DynamicRoutingNewVersionParamsElementsObjectProperties
Model string
Provider string
Retries float64
Timeout float64
Type DynamicRoutingNewVersionParamsElementsObjectType
type DynamicRoutingNewVersionParamsElementsObject struct{…}
ID string
Outputs map[string, DynamicRoutingNewVersionParamsElementsObjectOutputs]
ElementID string
Type DynamicRoutingNewVersionParamsElementsObjectType
ReturnsExpand Collapse
type DynamicRoutingNewVersionResponse struct{…}
ID string
CreatedAt Time
formatdate-time
Elements []DynamicRoutingNewVersionResponseElement
One of the following:
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionResponseElementsObjectOutputs
Type DynamicRoutingNewVersionResponseElementsObjectType
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionResponseElementsObjectOutputs
False DynamicRoutingNewVersionResponseElementsObjectOutputsFalse
ElementID string
True DynamicRoutingNewVersionResponseElementsObjectOutputsTrue
ElementID string
Properties DynamicRoutingNewVersionResponseElementsObjectProperties
Conditions unknownoptional
Type DynamicRoutingNewVersionResponseElementsObjectType
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs map[string, DynamicRoutingNewVersionResponseElementsObjectOutput]
ElementID string
Type DynamicRoutingNewVersionResponseElementsObjectType
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionResponseElementsObjectOutputs
Fallback DynamicRoutingNewVersionResponseElementsObjectOutputsFallback
ElementID string
Success DynamicRoutingNewVersionResponseElementsObjectOutputsSuccess
ElementID string
Properties DynamicRoutingNewVersionResponseElementsObjectProperties
Key string
Limit float64
LimitType DynamicRoutingNewVersionResponseElementsObjectPropertiesLimitType
One of the following:
const DynamicRoutingNewVersionResponseElementsObjectPropertiesLimitTypeCount DynamicRoutingNewVersionResponseElementsObjectPropertiesLimitType = "count"
const DynamicRoutingNewVersionResponseElementsObjectPropertiesLimitTypeCost DynamicRoutingNewVersionResponseElementsObjectPropertiesLimitType = "cost"
Window float64
Type DynamicRoutingNewVersionResponseElementsObjectType
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs DynamicRoutingNewVersionResponseElementsObjectOutputs
Fallback DynamicRoutingNewVersionResponseElementsObjectOutputsFallback
ElementID string
Success DynamicRoutingNewVersionResponseElementsObjectOutputsSuccess
ElementID string
Properties DynamicRoutingNewVersionResponseElementsObjectProperties
Model string
Provider string
Retries float64
Timeout float64
Type DynamicRoutingNewVersionResponseElementsObjectType
type DynamicRoutingNewVersionResponseElementsObject struct{…}
ID string
Outputs map[string, DynamicRoutingNewVersionResponseElementsObjectOutput]
ElementID string
Type DynamicRoutingNewVersionResponseElementsObjectType
GatewayID string
ModifiedAt Time
formatdate-time
Name string

Create a new AI Gateway Dynamic Route Version.

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"),
  )
  response, err := client.AIGateway.DynamicRouting.NewVersion(
    context.TODO(),
    "54442216",
    "54442216",
    ai_gateway.DynamicRoutingNewVersionParams{
      AccountID: cloudflare.F("0d37909e38d3e99c29fa2cd343ac421a"),
      Elements: cloudflare.F([]ai_gateway.DynamicRoutingNewVersionParamsElementUnion{ai_gateway.DynamicRoutingNewVersionParamsElementsObject{
        ID: cloudflare.F("id"),
        Outputs: cloudflare.F(ai_gateway.DynamicRoutingNewVersionParamsElementsObjectOutputs{
          Next: cloudflare.F(ai_gateway.DynamicRoutingNewVersionParamsElementsObjectOutputsNext{
            ElementID: cloudflare.F("elementId"),
          }),
        }),
        Type: cloudflare.F(ai_gateway.DynamicRoutingNewVersionParamsElementsObjectTypeStart),
      }}),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ID)
}
{
  "result": {
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "elements": [
      {
        "id": "id",
        "outputs": {
          "next": {
            "elementId": "elementId"
          }
        },
        "type": "start"
      }
    ],
    "gateway_id": "gateway_id",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name"
  },
  "success": true
}
Returns Examples
{
  "result": {
    "id": "id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "elements": [
      {
        "id": "id",
        "outputs": {
          "next": {
            "elementId": "elementId"
          }
        },
        "type": "start"
      }
    ],
    "gateway_id": "gateway_id",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name"
  },
  "success": true
}