-
Notifications
You must be signed in to change notification settings - Fork 36
feat(filter): add /v1/responses model rewrite filter for Codex passthrough #594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shaneutt
merged 3 commits into
praxis-proxy:main
from
nerdalert:brent-responses-passthrough
Jun 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <!-- Generated by: cargo xtask generate-filter-docs --> | ||
| <!-- Do not edit manually --> | ||
|
|
||
| # `openai_responses_model_rewrite` | ||
|
|
||
| Rewrites the `model` field in Responses API request bodies. | ||
|
|
||
| Requires Cargo feature: `ai-inference`. | ||
|
|
||
| ## Configuration | ||
|
|
||
| | Field | Type | Required | Description | | ||
| |-------|------|---------|-------------| | ||
| | `default_model` | string | no | Model name to inject when the request body has no `model` field or when the field is `null`. | | ||
| | `headers` | ModelRewriteHeaders | no | Header names for promoted model values. | | ||
| | `headers.effective_model` | string | no | Header name for the effective (post-rewrite) model value. | | ||
| | `headers.original_model` | string | no | Header name for the original (pre-rewrite) model value. | | ||
| | `max_body_bytes` | usize | no | Maximum request body size to buffer before parsing. | | ||
| | `model_aliases` | object<string, string> | no | Map from client-facing model names to backend model names. | | ||
| | `on_invalid` | `continue` \| `reject` | no | Behavior when the body is not valid JSON. | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1 | ||
|
|
||
| ```yaml | ||
| filter: openai_responses_model_rewrite | ||
| default_model: "llama-3.3-70b" | ||
| model_aliases: | ||
| codex-mini-latest: "llama-3.3-70b" | ||
| gpt-4.1-mini: "qwen-2.5-72b" | ||
| ``` | ||
|
|
||
| ### Example 2 | ||
|
|
||
| ```yaml | ||
| filter: openai_responses_model_rewrite | ||
| default_model: "llama-3.3-70b" | ||
| model_aliases: | ||
| codex-mini-latest: "llama-3.3-70b" | ||
| max_body_bytes: 10485760 | ||
| on_invalid: continue | ||
| headers: | ||
| effective_model: x-praxis-ai-effective-model | ||
| original_model: x-praxis-ai-original-model | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Responses Model Rewrite | ||
| # | ||
| # Rewrites or injects the top-level `model` field in Responses API | ||
| # request bodies before forwarding to the inference backend. | ||
| # | ||
| # This pipeline uses `openai_responses_format` to classify the | ||
| # request, then `openai_responses_model_rewrite` to apply alias | ||
| # mapping. The router uses the effective model header to select | ||
| # the backend cluster, so routing reflects the rewritten model, | ||
| # not the original client-facing name. | ||
| # | ||
| # Use case: Codex or other Responses API clients send | ||
| # `model: "codex-mini-latest"` and the proxy transparently | ||
| # rewrites it to a locally-hosted model before forwarding. | ||
| # | ||
| # Requires the ai-inference feature: | ||
| # cargo build -p praxis --features ai-inference | ||
|
|
||
| listeners: | ||
| - name: ai-gateway | ||
| address: "127.0.0.1:8080" | ||
| filter_chains: [model-rewrite-pipeline] | ||
|
|
||
| filter_chains: | ||
| - name: model-rewrite-pipeline | ||
| filters: | ||
| - filter: openai_responses_format | ||
| on_invalid: continue | ||
| headers: | ||
| format: x-praxis-ai-format | ||
| model: x-praxis-ai-model | ||
|
|
||
| - filter: openai_responses_model_rewrite | ||
| default_model: "llama-3.3-70b" | ||
| model_aliases: | ||
| codex-mini-latest: "llama-3.3-70b" | ||
| gpt-4.1-mini: "qwen-2.5-72b" | ||
| headers: | ||
| effective_model: x-praxis-ai-effective-model | ||
| original_model: x-praxis-ai-original-model | ||
|
|
||
| - filter: router | ||
| routes: | ||
| - path: "/v1/responses" | ||
| headers: | ||
| x-praxis-ai-effective-model: "llama-3.3-70b" | ||
| cluster: "llama-backend" | ||
| - path: "/v1/responses" | ||
| headers: | ||
| x-praxis-ai-effective-model: "qwen-2.5-72b" | ||
| cluster: "qwen-backend" | ||
| - path_prefix: "/" | ||
| cluster: "default-backend" | ||
|
|
||
| - filter: load_balancer | ||
| clusters: | ||
| - name: "llama-backend" | ||
| endpoints: | ||
| - "127.0.0.1:3001" | ||
| - name: "qwen-backend" | ||
| endpoints: | ||
| - "127.0.0.1:3002" | ||
| - name: "default-backend" | ||
| endpoints: | ||
| - "127.0.0.1:3003" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.