Skip to main content
Open Next Router’s DSL allows you to execute precise surgical strikes on HTTP requests and responses as they flow through the proxy, without writing any compiled middleware. This Cookbook covers common scenarios you might encounter when wrangling unruly prompts or mapping incompatible vendor schemas.

Header Injection & Stripping

Often, you must attach trailing analytics IDs, specific user-agent strings, or strip out sensitive Origin headers that your clients send.

Forcing Parameters (JSON Payload Manipulation)

If you want to enforce rules on your users (for instance, forcing a strict token limit, or ensuring a predictable temperature), you can mutate the JSON body dynamically.

Wrapping Responses Text Input

Some clients send a simple string as input, while an upstream expects the OpenAI Responses message-list shape.
This converts:
into:
Missing input fields and values that are already arrays are left unchanged. Other value types are rejected.

Cross-Provider Schema Mapping

One of ONR’s superpowers is translating an OpenAI-formatted chat.completions array into a format understood by Google Gemini or Anthropic Claude, and seamlessly re-mapping the response back instantly. To do this, simply use the req_map and resp_map directives.

Filtering Streaming Chunk Metadata

Sometimes, providers leak verbose metadata inside Server-Sent Event (SSE) streams that you decide isn’t useful for the client to parse, wasting bandwidth. You can selectively strip fields from specific streaming events using conditional logic: