Skip to main content
The ONR DSL is intentionally declarative, meaning there is no Turing-complete scripting language embedded. However, you can use built-in variables to dynamically construct paths, headers, and keys.

Expression Contexts

In positions where the DSL requires an <expr>, you can use:
  1. String Literal: "abc"
  2. Variable: $channel.key
  3. Function: concat("Bearer ", $channel.key)
Note: Variables are only evaluated when used as bare expressions. If you wrap them in double quotes (e.g., "$channel.key"), they are treated as plain string literals and will not be expanded.

Built-in Variables

These variables are populated at runtime dynamically for every request.

channel.* context

  • $channel.base_url: The channel base URL (string). Overrides upstream_config.base_url if set by the API caller.
  • $channel.key: The downstream API key/token (string) meant to be passed to the upstream provider.

request.* context

  • $request.model: The original requested model name from the upstream JSON body.
  • $request.model_mapped: The transformed model name, determined after any model_map operations fire.

Expression Examples

request {
  # Set a custom header based on the target mapped model
  set_header "x-upstream-model" $request.model_mapped;
}

upstream {
  # Dynamically construct the path
  set_path concat("/v1/", $request.model_mapped, "/chat/completions");
  
  # Inject query strings dynamically
  set_query key $channel.key;
}