Skip to main content
The 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 or delete HTTP headers going to the upstream server.
request {
  set_header "x-trace-id" "trace-123";
  set_header "x-foo" concat("a-", $request.model_mapped);
  
  del_header "x-remove-me";
}
Note: If the same header is set multiple times, the last one wins. Deletions apply in order.

Model Mapping

Use model_map to alias or hardcode model names conditionally.
request {
  model_map "gpt-4o-mini" "gpt4o-mini-prod";
  model_map "gpt-4o-mini" $request.model;
  
  model_map_default $request.model;
}
  • Maps $request.model to $request.model_mapped.
  • Exact match on the from string.
  • If no matches occur, model_map_default dictates what $request.model_mapped becomes.

JSON Mutations

Apply lightweight mutations directly to the upstream JSON body.
request {
  json_set "$.stream" true;
  json_set_if_absent "$.instructions" "";
  
  json_rename "$.max_tokens" "$.max_completion_tokens";
  json_wrap_input_text "$.input";
  json_del "$.tools";
}
  • Supports a subset of object-path JSONPath expressions (e.g. $.a.b.c).
  • json_set values support primitives (true, false, null, integers, strings) or expressions (like concat(...)).
  • json_wrap_input_text converts a string field into an OpenAI Responses input message list, leaves missing or already-array values unchanged, and rejects other types.

Structural Request Mapping

Use req_map to apply heavy, cross-provider schema transformations (such as converting an OpenAI JSON request into a Gemini or Anthropic JSON request).
request { req_map <mode>; }
Use after_req_map when a request JSON mutation must run after the structural mapping step.
request {
  req_map openai_chat_to_anthropic_messages;

  after_req_map {
    json_set "$.anthropic_version" "bedrock-2023-05-31";
    json_del_if_missing "$.tool_choice" "$.tools";
  }
}
  • Only request JSON mutation directives are allowed inside after_req_map.
  • If no req_map is configured, after_req_map runs after the normal request JSON operations.

Built-in Modes (v0.1)

  • openai_chat_to_openai_responses
  • anthropic_to_openai_chat
  • gemini_to_openai_chat
  • openai_chat_to_gemini_generate_content
  • openai_chat_to_anthropic_messages