Add OpenRouter app attribution headers#3
Open
jatmn wants to merge 2 commits into
Open
Conversation
Automatically attach OpenRouter app attribution headers (HTTP-Referer, X-OpenRouter-Title, X-OpenRouter-Categories) whenever a provider's base_url points at openrouter.ai, so Codex Warp usage appears in OpenRouter's public rankings and analytics. - Inject attribution in apply_headers_with_accept (src/http.rs), covering chat completions, native /responses, and /models - User-set [providers.<id>.headers] override the automatic values - Add configs/openrouter.toml profile and document in README - Add unit tests in src/http_tests.rs
jatmn
force-pushed
the
feat/openrouter-app-attribution
branch
from
July 12, 2026 04:40
b0fd025 to
c0a5939
Compare
- Detect OpenRouter by the parsed host (== openrouter.ai or a *.openrouter.ai subdomain) instead of a raw substring match, so look-alike hosts (e.g. openrouter.ai.attacker.example) are no longer misidentified as OpenRouter. - Add tests for case-insensitive host, subdomain, look-alike false-positive, X-Title alias suppression, X-OpenRouter-Categories override, and /responses + /models paths; assert exactly one value per header to catch duplicate-header regressions. - Document the opt-out/override and update detection wording in the README and configs/openrouter.toml. - Use a mut request parameter and add a rationale comment for the hardcoded identity values. Validated: cargo fmt --check, cargo build --locked, cargo test --locked (134 passing).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds OpenRouter app attribution support so Codex Warp's OpenRouter usage appears in OpenRouter's public rankings and analytics.
base_urlcontainsopenrouter.ai, in the single outgoing-header chokepointapply_headers_with_accept(covers chat completions, native/responses, and/models):HTTP-Referer:https://github.com/jatmn/Codex-warpX-OpenRouter-Title:Codex WarpX-OpenRouter-Categories:cli-agent,programming-app[providers.<id>.headers]take precedence (the automatic header is skipped if already set).configs/openrouter.tomlprofile (base_url,api_key_env = "OPENROUTER_API_KEY", standard paths) and added it to the commentedincludelist incodex-warp.toml.README.mdand added unit tests insrc/http_tests.rs(present for OpenRouter, absent for other providers, user override wins).Test plan
cargo test— all 128 tests pass (incl. 3 new attribution tests).cargo build— succeeds (one pre-existing unrelated dead-code warning).🤖 Generated with opencode