Skip to main content
POST
/
api
/
governance
/
routing-rules
Create routing rule
curl --request POST \
  --url http://localhost:8080/api/governance/routing-rules \
  --header 'Content-Type: application/json' \
  --data '
{
  "scope": "global",
  "name": "<string>",
  "cel_expression": "<string>",
  "targets": [
    {
      "weight": 0.5,
      "provider": "<string>",
      "model": "<string>",
      "key_id": "<string>"
    }
  ],
  "priority": 123,
  "description": "<string>",
  "enabled": true,
  "fallbacks": [
    "<string>"
  ],
  "scope_id": "<string>",
  "query": {}
}
'
{
  "message": "<string>",
  "rule": {
    "scope": "global",
    "id": "<string>",
    "name": "<string>",
    "description": "<string>",
    "enabled": true,
    "cel_expression": "<string>",
    "targets": [
      {
        "weight": 0.5,
        "provider": "<string>",
        "model": "<string>",
        "key_id": "<string>"
      }
    ],
    "fallbacks": [
      "<string>"
    ],
    "scope_id": "<string>",
    "priority": 123,
    "query": {},
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}

Body

application/json

Request to create a routing rule

scope
enum<string>
required

Scope level for the rule

Available options:
global
name
string
required

Name of the routing rule

cel_expression
string
required

CEL expression for matching

targets
object[]
required

Weighted routing targets; weights must sum to 1; target is selected probabilistically at request time

Minimum array length: 1
priority
integer
required

Priority for rule evaluation (lower number = higher priority)

description
string

Optional description

enabled
boolean

Whether the rule is enabled

fallbacks
string[]

Fallback providers in format "provider/model"

scope_id
string | null

ID for the scope (required if scope is not global)

query
object

Visual rule tree structure

Response

Routing rule created successfully

Response containing created/updated routing rule

message
string
rule
object

CEL-based routing rule for intelligent request routing