> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional Routing

Using AI Gateway, you can route your requests to different provider targets based on custom conditions you define. These can be conditions like:

* If this user is on the `paid plan`, route their request to a `custom fine-tuned model`
* If the model parameter is set to `fastest`, route to `gpt-4o-mini`, if `smartest`, route to `openai o1`
* If this user is an `EU resident`, call an `EU hosted model`
* If the `temperature` parameter is above `0.7`, route to a more creative model
* If the request is coming from `testing environment` with a `llm-pass-through` flag, route it to the `cheapest model`
* ..and more!

Using this strategy, you can set up sophisticated routing logic based on:

1. **Metadata** - Custom key-value pairs you pass with your requests
2. **Request Parameters** - Any parameter that you send in your original LLM request (like model, temperature, max\_tokens)
3. **Request URL Path** - Match against `url.pathname` (for example, route `/v1/embeddings` requests)

All routing happens very fast on the *gateway*, on *edge*.

## Enabling Conditional Routing

Conditional routing is one of the *strategies* in the AI Gateway's [Gateway Configs](https://docs.portkey.ai/docs/aigw/product/ai-gateway/configs.md). (others being `fallback` and `loadbalance`). To use it in your app,

1. You need to create a `conditional` config in Strata Cloud Manager.
2. Save the Config and get an associated Config ID.
3. And just pass the Config ID along with your requests using the `config` param.

## 1. Creating the `conditional` Config

Here's how a sample `conditional` config looks (along with its simpler, tree view).

**Sample Config**

```json theme={"system"}
{
  "strategy": {
    "mode": "conditional",
    "conditions": [
      ...conditions
    ],
    "default": "target_1"
  },
  "targets": [
    {
      "name": "target_1",
      "provider": "@xx"
    },
    {
      "name": "target_2",
      "provider": "@yy"
    }
  ]
}
```

**Tree View**

```
│─ config
│  │─ strategy mode:conditional
│  │  │─ conditions
│  │  │  │─ array of conditions
│  │  │─ default
│  │  │  │─ target name
│  │─ targets
│  │  │─ target 1
│  │  │  │─ name
│  │  │  │─ provider details
│  │  │─ target 2
│  │  │  │─ name
│  │  │  │─ provider details
```

* `strategy.mode`: Set to `conditional`
* `strategy.conditions`: Query conditions with rules applied on metadata values or request parameters along with which target to call when the condition passes
* `strategy.default`: The default target name to call when none of the conditions pass
* `targets`: Array of target objects with unique `names` and provider details. These target names are referenced in the `conditions` objects above.

> [!NOTE]
>
> `conditions` and `default` are **required params** for the `conditional` strategy.

### Structure of `conditions` Object

`conditions` are where you will actually write the routing rules. Here's a sample `condition` object:

**Metadata Based**

```json theme={"system"}
  {
    "query": { "metadata.user_plan": { "$eq": "paid" } },
    "then": "finetuned-gpt4"
  }
```

**Params Based**

```json theme={"system"}
{
  "query": { "params.model": { "$eq": "smartest" } },
  "then": "smartest-model-target"
}
```

`query`: Write the exact rule for checking metadata values or request parameters

`then`: Define which target to call if the query `PASSES`

#### Supported Query Paths and Limits

* `metadata.<key>`: Looks up `context.metadata[<key>]`. Keys must be flat (no additional dots) and values should be primitive types.
* `params.<key>`: Looks up `context.params[<key>]`. Only primitive values are supported for comparisons.
* `url.pathname`: Matches against the full request path (for example, `/admin/users`).

Note: Only two-segment keys are supported (for example, `metadata.user_plan`, `params.model`). Nested paths like `metadata.features.new_model_enabled` are not supported.

### List of Condition Query Operators

| Operator | Description |
| - | - |
| `$eq` | Equals |
| `$ne` | Not equals |
| `$in` | In array |
| `$nin` | Not in array |
| `$regex` | Match the regex |
| `$gt` | Greater than |
| `$gte` | Greater than or equal to |
| `$lt` | Less than |
| `$lte` | Less than or equal to |

> [!NOTE]
>
> * `$regex` uses JavaScript regular expressions with no flags. Matching is case-sensitive by default, and invalid patterns simply cause the condition to evaluate to `false`.

### Logical Query Operators

* `$and`: All conditions must be true
* `$or`: At least one condition must be true

\*\* Example Condition objects with Logical Operators\*\*

**AND**

```json theme={"system"}
{
  "$and": [
    { "metadata.user_type": { "$eq": "pro" } },
    { "metadata.model": { "$eq": "gpt-4" } }
  ]
}
```

**OR**

```json theme={"system"}
{
  "$or": [
    { "params.temperature": { "$gt": 0.7 } },
    { "params.top_p": { "$lt": 0.8 } }
  ]
}
```

**MIXED Conditions**

```json theme={"system"}
{
  "$or": [
    {
      "$and": [
        { "metadata.user_type": { "$eq": "pro" } },
        { "params.model": { "$eq": "gpt-4o" } }
      ]
    },
    { "params.max_tokens": { "$gt": 1000 } }
  ]
}
```

> [!NOTE]
>
> 1. You can write nested queries (with `$and`, `$or` operators)
> 2. When a condition evaluates to `false` or is malformed, the AI Gateway moves on to the next condition until it finds a successful one.
> 3. If no conditions pass, then the `default` target name is called
> 4. Since the AI Gateway iterates through the queries sequentially, the order of your conditions is important
> 5. If a referenced key is missing (in `metadata`, `params`, or `url`), the condition evaluates to `false`; it does not throw an error.

## 2. Getting Config ID

Based on the `conditions` and the Config structure described above, you can create your [Config in Strata Cloud Manager](https://stratacloudmanager.paloaltonetworks.com/), and save it to get Config ID. The UI also helps you autofill and autoformat your Config.

## 3. Implementing Conditional Routing

Conditional routing is enabled through the AI Gateway's [Gateway Configs](https://docs.portkey.ai/docs/aigw/product/ai-gateway/configs.md) by following these steps:

1. Create a conditional config in Strata Cloud Manager ([stratacloudmanager.paloaltonetworks.com](https://stratacloudmanager.paloaltonetworks.com/))
2. Save the config to get a Config ID
3. Use this Config ID in your requests

> **[Parameter-Based Routing](#routing-based-on-request-parameters)**
>
> Route requests based on the values of parameters like `model`, `temperature`, or `max_tokens`

> **[Metadata-Based Routing](#routing-based-on-metadata)**
>
> Route requests based on custom metadata fields you include with your request

You can also combine both approaches for [more sophisticated routing logic](#combined-routing-with-multiple-conditions)

### Routing Based on Request Parameters

With conditional routing, you can route based on any parameter in your LLM request (`model`, `temperature`, `max_tokens`, etc.).

> [!NOTE]
>
> The AI Gateway only supports params routing for primitive types (string, number, boolean). Complex types like arrays and objects are not supported.

**Example: Model Parameter Based Routing**

This example routes based on the `model` parameter, allowing you to use aliases instead of specific model names:

```json theme={"system"}
{
  "strategy": {
    "mode": "conditional",
    "conditions": [
      {
        "query": {
          "params.model": {
            "$eq": "fastest"
          }
        },
        "then": "fastest-model-target"
      },
      {
        "query": {
          "params.model": {
            "$eq": "smartest"
          }
        },
        "then": "smartest-model-target"
      }
    ],
    "default": "fastest-model-target"
  },
  "targets": [
    {
      "name": "smartest-model-target",
      "provider":"@anthropic-vk",
      "override_params": {
        "model": "claude-3.5-sonnet"
      }
    },
    {
      "name": "fastest-model-target",
      "provider":"@oai-vk",
      "override_params": {
        "model": "gpt-4o-mini"
      }
    }
  ]
}
```

Using the config:

> [!NOTE]
>
> When using parameter-based routing, make sure to include the parameter specified in your routing condition in your request. In the example above, you need to include `model` in your request for routing to work properly.

### Routing Based on Metadata

Palo Alto Networks support [metadata](https://docs.portkey.ai/docs/aigw/product/observability/metadata.md)-based routing, which requires sending custom metadata with your request.

**Applying Conditional Routing Based on Metadata**

**Simple Conditional Config**

In this example we are routing our request based on `user_plan` metadata sent along request. If the user is on a `paid` plan, we route to a `finetuned-gpt4` model, otherwise we route to a `base-gpt4` model.

```json theme={"system"}
{
  "strategy": {
    "mode": "conditional",
    "conditions": [
      {
        "query": { "metadata.user_plan": { "$eq": "paid" } },
        "then": "finetuned-gpt4"
      },
      {
        "query": { "metadata.user_plan": { "$eq": "free" } },
        "then": "base-gpt4"
      }
    ],
    "default": "base-gpt4"
  },
  "targets": [
    {
      "name": "finetuned-gpt4",
      "provider": "@xx",
      "override_params": {
          "model": "ft://gpt4-xxxxx"
      }
    },
    {
      "name": "base-gpt4",
      "provider": "@yy",
      "override_params": {
          "model": "gpt-4"
      }
    }
  ]
}
```

**Nested Conditional Config**

```json theme={"system"}
{
  "strategy": {
    "mode": "conditional",
    "conditions": [
      {
        "query": {
          "$and": [
            { "metadata.user_type": { "$eq": "pro" } },
            { "metadata.user_tier": { "$eq": "tier-1" } }
          ]
        },
        "then": "gpt4_v2_target"
      },
      {
        "query": {
          "$or": [
            { "metadata.client": { "$eq": "UI" } },
            { "metadata.app_name": { "$regex": "my_app" } }
          ]
        },
        "then": "app_target"
      }
    ],
    "default": "default_target"
  },
  "targets": [
    { "name": "gpt4_v2_target", "provider":"@openai-xx"},
    { "name": "app_target", "provider":"@openai-yy" },
    { "name": "default_target", "provider":"@openai-zz" }
  ]
}
```

Using the config:

> [!NOTE]
>
> You can combine both metadata and request parameters in your conditions. For example, you can route based on a combination of `metadata.user_plan` and `params.model`.

### Combined Routing with Multiple Conditions

You can combine metadata and parameter conditions for more sophisticated routing:

Config example for combined conditions:

```json theme={"system"}
{
  "strategy": {
    "mode": "conditional",
    "conditions": [
      {
        "query": {
          "$and": [
            { "metadata.user_tier": { "$eq": "enterprise" } },
            { "params.temperature": { "$gte": 0.7 } }
          ]
        },
        "then": "creative-premium-target"
      }
    ],
    "default": "standard-target"
  },
  "targets": [
    {
      "name": "creative-premium-target",
      "provider":"@anthropic-vk",
      "override_params": { "model": "claude-3-opus" }
    },
    {
      "name": "standard-target",
      "provider":"@openai-vk",
      "override_params": { "model": "gpt-3.5-turbo" }
    }
  ]
}
```

## More Examples Using Conditional Routing

Here are practical examples of how you can leverage conditional routing to handle real-world challenges in your LLM applications. These examples showcase common patterns that help optimize cost, performance, compliance, and feature deployment without changing your application code.

> **User-Based Routing**
>
> **User Subscription Tier**
>
> Route premium users to advanced models and free users to cost-effective ones.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.user_tier": { "$eq": "premium" } },
>         "then": "premium-model"
>       },
>       {
>         "query": { "metadata.user_tier": { "$eq": "free" } },
>         "then": "basic-model"
>       }
>     ],
>     "default": "basic-model"
>   },
>   "targets": [
>     {
>       "name": "premium-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     },
>     {
>       "name": "basic-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-3.5-turbo" }
>     }
>   ]
> }
> ```
>
> **Regional Compliance**
>
> Ensure GDPR compliance by routing EU users to EU-compliant deployments.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.user_region": { "$eq": "EU" } },
>         "then": "eu-compliant"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     {
>       "name": "eu-compliant", "provider":"@azure-eu-vk",
>       "override_params": { "model": "gpt-4" }
>     },
>     {
>       "name": "standard-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     }
>   ]
> }
> ```
>
> **Data Sensitivity**
>
> Route requests to different models based on data sensitivity levels.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.data_sensitivity": { "$eq": "high" } },
>         "then": "on-premises-model"
>       },
>       {
>         "query": { "metadata.data_sensitivity": { "$in": ["medium", "low"] } },
>         "then": "cloud-model"
>       }
>     ],
>     "default": "public-model"
>   },
>   "targets": [
>     {
>       "name": "public-model", "provider":"@openai-vk" },
>     {
>       "name": "on-premises-model", "provider":"@private-vk" },
>     {
>       "name": "cloud-model", "provider":"@azure-vk" }
>   ]
> }
> ```

> **Model Selection & Parameter Routing**
>
> **Routing Based on Model Name Aliases**
>
> Use intuitive aliases instead of remembering specific model names.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "params.model": { "$eq": "fastest" } },
>         "then": "fast-model"
>       },
>       {
>         "query": { "params.model": { "$eq": "smartest" } },
>         "then": "smart-model"
>       }
>     ],
>     "default": "balanced-model"
>   },
>   "targets": [
>     {
>       "name": "smart-model", "provider":"@anthropic-vk",
>       "override_params": { "model": "claude-3.5-sonnet" }
>     },
>     {
>       "name": "fast-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o-mini" }
>     },
>     {
>       "name": "balanced-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     }
>   ]
> }
> ```
>
> **Model Hyperparam Based Routing**
>
> Route creative vs factual requests to different optimized models.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "params.temperature": { "$gte": 0.7 } },
>         "then": "creative-model"
>       },
>       {
>         "query": { "params.temperature": { "$lt": 0.3 } },
>         "then": "factual-model"
>       }
>     ],
>     "default": "balanced-model"
>   },
>   "targets": [
>     {
>       "name": "creative-model", "provider":"@anthropic-vk",
>       "override_params": { "model": "claude-3-sonnet" }
>     },
>     {
>       "name": "factual-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     },
>     {
>       "name": "balanced-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-3.5-turbo" }
>     }
>   ]
> }
> ```
>
> **Max Tokens Based Routing**
>
> Route high-token requests to models with larger context windows.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "params.max_tokens": { "$gt": 4000 } },
>         "then": "high-capacity"
>       }
>     ],
>     "default": "standard-capacity"
>   },
>   "targets": [
>     {
>       "name": "high-capacity", "provider":"@anthropic-vk",
>       "override_params": { "model": "claude-3-opus" }
>     },
>     {
>       "name": "standard-capacity", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o-mini" }
>     }
>   ]
> }
> ```

> **Application Features & Testing**
>
> **Task-Specific Routing**
>
> Route different tasks to specialized models for optimal results.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.task": { "$eq": "coding" } },
>         "then": "coding-model"
>       },
>       {
>         "query": { "metadata.task": { "$eq": "writing" } },
>         "then": "writing-model"
>       }
>     ],
>     "default": "general-model"
>   },
>   "targets": [
>     {
>       "name": "coding-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     },
>     {
>       "name": "writing-model", "provider":"@anthropic-vk",
>       "override_params": { "model": "claude-3-opus" }
>     },
>     {
>       "name": "general-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-3.5-turbo" }
>     }
>   ]
> }
> ```
>
> **A/B Testing**
>
> Test new models with specific user groups before full rollout.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.user_group": { "$eq": "beta" } },
>         "then": "new-model"
>       }
>     ],
>     "default": "current-model"
>   },
>   "targets": [
>     {
>       "name": "new-model", "provider":"@anthropic-vk",
>       "override_params": { "model": "claude-3.5-sonnet" }
>     },
>     {
>       "name": "current-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-3.5-turbo" }
>     }
>   ]
> }
> ```
>
> **Feature Flags**
>
> Control feature rollout with feature flags in metadata.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "metadata.new_model_enabled": { "$eq": true } },
>         "then": "new-model-target"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     {
>       "name": "new-model-target", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-4o" }
>     },
>     {
>       "name": "standard-model", "provider":"@openai-vk",
>       "override_params": { "model": "gpt-3.5-turbo" }
>     }
>   ]
> }
> ```

> **URL Path Routing**
>
> **Route by URL Path**
>
> Match requests based on the incoming request path.
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": { "url.pathname": { "$regex": "^/responses" } },
>         "then": "responses-model"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     { "name": "responses-model", "provider": "@openai-vk/gpt-4.1" },
>     { "name": "standard-model", "provider": "@openai-vk/gpt-3.5-turbo" }
>   ]
> }
> ```

> **Using Conditional Router with Guardrails**
>
> **Input Guardrails**
>
> You can apply input guardrails to specific targets in your conditional routing configuration. This allows you to validate or transform the input before it's sent to the LLM:
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": {
>           "metadata.user_plan": { "$eq": "paid" }
>         },
>         "then": "premium-model"
>       },
>       {
>         "query": {
>           "metadata.user_plan": { "$eq": "free" }
>         },
>         "then": "standard-model"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     {
>       "name": "premium-model",
>       "provider":"@openai-vk-xxx",
>       "input_guardrails": ["pg-pii-detector-xxx", "pg-toxic-content-xxx"]
>     },
>     {
>       "name": "standard-model",
>       "provider":"@openai-vk-yyy"
>     }
>   ]
> }
> ```
>
> In this example, when a user with the "paid" plan sends a request, it's routed to the premium model but first runs through two input guardrails: one for PII detection and another for toxic content filtering.
>
> **Output Guardrails**
>
> You can also apply output guardrails to validate or transform the LLM's response:
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": {
>           "params.temperature": { "$gte": 0.7 }
>         },
>         "then": "creative-model"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     {
>       "name": "creative-model",
>       "provider":"@anthropic-vk-xxx",
>       "output_guardrails": [
>         "pg-fact-checker-xxx",
>         "pg-content-moderator-xxx"
>       ]
>     },
>     {
>       "name": "standard-model",
>       "provider":"@openai-vk-xxx"
>     }
>   ]
> }
> ```
>
> This configuration applies output guardrails to the "creative-model" target, which is used when the temperature parameter is high. The response from this model will be checked for factual accuracy and moderated for inappropriate content.
>
> **Both Input and Output Guardrails**
>
> For comprehensive protection, you can apply both input and output guardrails to your targets:
>
> ```json theme={"system"}
> {
>   "strategy": {
>     "mode": "conditional",
>     "conditions": [
>       {
>         "query": {
>           "metadata.user_plan": { "$eq": "paid" }
>         },
>         "then": "premium-model"
>       },
>       {
>         "query": {
>           "metadata.user_plan": { "$eq": "free" }
>         },
>         "then": "standard-model"
>       }
>     ],
>     "default": "standard-model"
>   },
>   "targets": [
>     {
>       "name": "premium-model",
>       "provider":"@openai-vk-xxx",
>       "input_guardrails": ["pg-pii-detector-xxx", "pg-toxic-content-xxx"],
>       "output_guardrails": ["pg-fact-checker-xxx", "pg-compliance-xxx"]
>     },
>     {
>       "name": "standard-model",
>       "provider":"@openai-vk-yyy",
>       "input_guardrails": ["pg-basic-filter-xxx"],
>       "output_guardrails": ["pg-basic-moderator-xxx"]
>     }
>   ]
> }
> ```
>
> This configuration provides end-to-end protection by:
>
> 1. First checking inputs with guardrails before sending to the LLM
> 2. Then validating outputs with guardrails before returning to the user
>
> Each target can have its own set of guardrails, allowing you to apply different levels of protection based on your routing conditions.
>
> > [!NOTE]
> >
> > Guardrails are referenced by their IDs in the configuration. You can create guardrails in Strata Cloud Manager and then reference them in your conditional routing config.
> >
> > Learn more about [AI Gateway Guardrails](https://docs.portkey.ai/docs/aigw/product/guardrails.md) to understand how to create and manage different types of guardrails for your LLM applications.

## Combine with Other Strategies

Conditional routing targets are fully composable — each target can itself be a load balancer, a fallback chain, or another conditional router. Any strategy can nest inside any other.

> **[Scale One Model Across Multiple Providers](https://docs.portkey.ai/docs/guides/use-cases/combining-routing-strategies.md#scale-one-model-across-multiple-providers)**
>
> Route a model alias to a load balancer spanning Anthropic, Vertex AI, and Bedrock — triple the rate limits with no code changes.

> **[Give Each Model Its Own Fallback](https://docs.portkey.ai/docs/guides/use-cases/combining-routing-strategies.md#give-each-model-its-own-fallback)**
>
> Each conditional branch has its own independent fallback chain — an OpenAI outage only affects the GPT-4o branch, not Claude routing.

> **[Smart Failover by Request Context](https://docs.portkey.ai/docs/guides/use-cases/combining-routing-strategies.md#smart-failover-by-request-context)**
>
> When the primary fails, a conditional router picks the best backup based on request context — keeping EU users on EU infrastructure even during outages.

> **[Isolate Failures Between Model Families](https://docs.portkey.ai/docs/guides/use-cases/combining-routing-strategies.md#isolate-failures-between-model-families)**
>
> Each load-balanced slot has its own failover. An OpenAI outage only affects that slot — Anthropic traffic continues uninterrupted.

## Important Note

1. **Parameter Presence**: When routing based on request parameters, make sure the parameters specified in your conditions are included in your requests.

2. **Primitive Types Only**: Parameter-based routing works with primitive data types (strings, numbers, booleans) but not with arrays or nested objects.

3. **Order Matters**: Conditions are evaluated in the order they're defined, so place more specific conditions before more general ones.

4. **Missing Keys Do Not Error**: If your condition references a parameter or metadata key that doesn't exist in the request, the condition evaluates to `false`. The router tries the next condition, and if none pass, uses the `default` target.

5. **Multiple Parameter Types**: The AI Gateway supports routing based on any parameter that can be sent in LLM requests including `model`, `temperature`, `top_p`, `frequency_penalty`, `presence_penalty`, `max_tokens`, and many others.

6. **Supported Query Paths**: `metadata.<key>`, `params.<key>`, and `url.pathname`. Nested paths beyond these (for example, `metadata.a.b`) are not supported.


## Related topics

- [Strands Agents](https://docs.portkey.ai/docs/aigw/integrations/agents/strands.md)
- [Langchain (JS/TS)](https://docs.portkey.ai/docs/aigw/integrations/libraries/langchain-js.md)
- [Dashscope](https://docs.portkey.ai/docs/aigw/integrations/llms/dashscope.md)
- [Claude for Microsoft 365](https://docs.portkey.ai/docs/aigw/integrations/libraries/claude-for-microsoft-365.md)
- [Langchain (Python)](https://docs.portkey.ai/docs/aigw/integrations/libraries/langchain-python.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.