feat: add appName and appUrl options for app identification headers#425
Open
robert-j-y wants to merge 4 commits intomainfrom
Open
feat: add appName and appUrl options for app identification headers#425robert-j-y wants to merge 4 commits intomainfrom
robert-j-y wants to merge 4 commits intomainfrom
Conversation
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
X-OpenRouter-Title is the current canonical header per OpenRouter docs. X-Title is still supported for backwards compatibility but new code should use the preferred name. Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
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.
Description
Adds
appNameandappUrlas first-class options oncreateOpenRouter()so users can set app identification headers without manually constructing aheadersobject.Before:
After:
Updates since last revision
OpenRouterclass infacade.ts: The class now wiresappName/appUrlinto itsbaseConfigheaders, matching thecreateOpenRouter()behavior. Previously these options were silently ignored through the deprecated path.Key details for review
appNamemaps toX-OpenRouter-Title,appUrlmaps toHTTP-Referer— these are the canonical headers per OpenRouter app attribution docs.appName/appUrlare spread beforeoptions.headersin bothcreateOpenRouter()and the deprecatedOpenRouterclass, so explicitheadersentries take priority. This is covered by a dedicated test forcreateOpenRouter().&&guard.Items for human review
The changeset file references— Fixed: changeset now correctly referencesX-TitleX-OpenRouter-Title.The deprecated— Fixed:OpenRouterclass infacade.tssilently ignoresappName/appUrlfacade.tsnow stores and wires both options into headers.OpenRouterfacade class withappName/appUrl— the 5 existing tests covercreateOpenRouter()only. The facade wiring uses the same spread pattern, but has no test coverage.@openrouter/sdkstill uses the legacyX-Titleheader name. This PR intentionally uses the current canonicalX-OpenRouter-Titleper OpenRouter docs — be aware of the difference across SDKs.Changes
src/provider.ts: AddedappNameandappUrltoOpenRouterProviderSettingsinterface; wired intogetHeaders()asX-OpenRouter-TitleandHTTP-Refererrespectively.src/facade.ts: WiredappNameandappUrlinto the deprecatedOpenRouterclass constructor andbaseConfigheaders, matchingcreateOpenRouter()behavior.src/tests/provider-options.test.ts: 5 new tests covering individual headers, both together, custom header override precedence, and absence when not provided..changeset/add-app-name-url.md: Minor changeset for the new feature.Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests pass (248/248)Changeset
pnpm changesetto create a changeset file (minor)Link to Devin session: https://app.devin.ai/sessions/a4b5cbff5a0448aa89aa45557aa32161
Requested by: @robert-j-y