Skip to content

Add OpenRouter app attribution headers#3

Open
jatmn wants to merge 2 commits into
mainfrom
feat/openrouter-app-attribution
Open

Add OpenRouter app attribution headers#3
jatmn wants to merge 2 commits into
mainfrom
feat/openrouter-app-attribution

Conversation

@jatmn

@jatmn jatmn commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Adds OpenRouter app attribution support so Codex Warp's OpenRouter usage appears in OpenRouter's public rankings and analytics.

  • Automatically attach attribution headers whenever a provider's base_url contains openrouter.ai, in the single outgoing-header chokepoint apply_headers_with_accept (covers chat completions, native /responses, and /models):
    • HTTP-Referer: https://github.com/jatmn/Codex-warp
    • X-OpenRouter-Title: Codex Warp
    • X-OpenRouter-Categories: cli-agent,programming-app
  • User-supplied headers in [providers.<id>.headers] take precedence (the automatic header is skipped if already set).
  • New configs/openrouter.toml profile (base_url, api_key_env = "OPENROUTER_API_KEY", standard paths) and added it to the commented include list in codex-warp.toml.
  • Documented in README.md and added unit tests in src/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

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
jatmn force-pushed the feat/openrouter-app-attribution branch from b0fd025 to c0a5939 Compare July 12, 2026 04:40
- 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant