Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Evaluates a condition against the [request metadata](#request-metadata) and rout
- `true`: Forwards request to provided element if condition evaluates to true
- `false`: Forwards request to provided element if condition evaluates to false

`conditions` supports MongoDB-like operators such as `$eq`, `$ne`, `$in`, `$and`, and `$or`. If the request does not include a metadata key, the condition evaluates the key as missing. For example, `$eq` evaluates to false and `$ne` evaluates to true.
`conditions` supports MongoDB-like operators such as `$eq`, `$ne`, `$in`, `$and`, and `$or`, plus `$contains` to [match one entry in a list](#match-one-entry-in-a-list). If the request does not include a metadata key, the condition evaluates the key as missing. For example, `$eq` evaluates to false and `$ne` evaluates to true.

```json
{
Expand All @@ -78,6 +78,22 @@ Evaluates a condition against the [request metadata](#request-metadata) and rout
}
```

#### Match one entry in a list

Metadata values cannot be arrays. To send a list, such as the groups a user belongs to, send it as one comma-separated string and use `$contains` to check for one entry. This uses one [custom metadata](/ai-gateway/observability/custom-metadata/) key for the whole list.

For example, if you send `cf-aig-metadata: {"groups": "engineering,finance"}`, the following condition evaluates to true:

```json
{
"conditions": {
"metadata.groups": { "$contains": "finance" }
}
}
```

`$contains` splits the value on commas, trims spaces around each entry and around the operand, and matches an entry that equals the operand exactly. It is case-sensitive and matches whole entries only, so `finance` does not match `finance-readonly`. It evaluates to false when the key is missing or its value is not a string. You can combine it with `$and`, `$or`, and `$not`.

### Percentage Split

Routes requests probabilistically across multiple outputs, useful for A/B testing and gradual rollouts.
Expand Down