request block enables you to perform lightweight transformations on the payload before it gets sent to the upstream provider.
Header Operations
You can arbitrarily set, delete, or filter HTTP headers going to the upstream server.filter_header_values
Removes header value items that match any of the given patterns (denylist). Non-matching items are kept.- Syntax:
filter_header_values <header> <pattern>... [separator="<sep>"]; - Default separator is
,. Output is normalized (", "for comma,"<sep> "for others). - Pattern matching supports
*wildcards; case-insensitive is not applied (patterns must match the exact case used by the client). - If all values are removed, the header is deleted.
keep_header_values
Keeps only header value items that match any of the given patterns (allowlist). Non-matching items are removed.- Syntax:
keep_header_values <header> <pattern>... [separator="<sep>"]; - Mirror of
filter_header_valueswith inverted logic: patterns select what to keep. - Same separator and output formatting rules as
filter_header_values. - If no values match, the header is deleted.
Model Mapping
Usemodel_map to alias or hardcode model names conditionally.
- Maps
$request.modelto$request.model_mapped. - Exact match on the
fromstring. - If no matches occur,
model_map_defaultdictates what$request.model_mappedbecomes.
JSON Mutations
Apply lightweight mutations directly to the upstream JSON body.- Supports a subset of object-path JSONPath expressions (e.g.
$.a.b.c). json_setvalues support primitives (true,false,null, integers, strings) or expressions (likeconcat(...)).json_wrap_input_textconverts a string field into an OpenAI Responsesinputmessage list, leaves missing or already-array values unchanged, and rejects other types.json_keep_valuesfilters a JSON string array, keeping only values that match any pattern (allowlist). Use afterjson_set_header_valuesto restrict a header-sourced array to a known-safe set.json_filter_valuesfilters a JSON string array, removing values that match any pattern (denylist).- Both
json_keep_valuesandjson_filter_valuessupport*wildcards, are case-insensitive, and delete the field if no values remain.
Request Validation
Usereq_* rules to reject malformed client requests with HTTP 400 before they reach the upstream provider.
<source>isbody,header, orquery. Body targets use object-path ($.a.b.c, no array indices); header/query targets use the parameter name.- Rules run after
model_map(a$.modelrule sees the mapped model name) and before JSON mutations andreq_map, in DSL order —defaults.requestrules first, then matchedmatch.requestrules. The first failure stops validation and returns 400 withcode=request_validation_failed. req_requiredfails when the target is missing; JSONnullcounts as missing unlessallow_null=true(body only).req_forbidfails when the target is present. All other rules are no-ops for missing targets.req_type(body only) checksnull|bool|number|integer|string|array|object.req_rangechecks numeric bounds;req_lenchecks string length (Unicode code points) or array length.req_enumcompares body values as JSON literals and header/query values as strings.- If any
bodyrule is configured and the request has no JSON object body, the request is rejected; use only header/query rules for non-JSON APIs. - Error messages never include the actual field value.
Structural Request Mapping
Usereq_map to apply heavy, cross-provider schema transformations (such as converting an OpenAI JSON request into a Gemini or Anthropic JSON request).
after_req_map when a request JSON mutation must run after the structural mapping step.
- Only request JSON mutation directives are allowed inside
after_req_map. - If no
req_mapis configured,after_req_mapruns after the normal request JSON operations.
Built-in Modes (v0.1)
openai_chat_to_openai_responsesanthropic_to_openai_chatgemini_to_openai_chatopenai_chat_to_gemini_generate_contentopenai_chat_to_anthropic_messages