Skip to content

feat: add appName and appUrl options for app identification headers#425

Open
robert-j-y wants to merge 4 commits intomainfrom
devin/1772572718-add-app-name-url
Open

feat: add appName and appUrl options for app identification headers#425
robert-j-y wants to merge 4 commits intomainfrom
devin/1772572718-add-app-name-url

Conversation

@robert-j-y
Copy link
Copy Markdown
Contributor

@robert-j-y robert-j-y commented Mar 3, 2026

Description

Adds appName and appUrl as first-class options on createOpenRouter() so users can set app identification headers without manually constructing a headers object.

Before:

const openrouter = createOpenRouter({
  apiKey: 'sk-...',
  headers: {
    'X-OpenRouter-Title': 'My App',
    'HTTP-Referer': 'https://myapp.com',
  },
});

After:

const openrouter = createOpenRouter({
  apiKey: 'sk-...',
  appName: 'My App',
  appUrl: 'https://myapp.com',
});

Updates since last revision

  • Fixed deprecated OpenRouter class in facade.ts: The class now wires appName/appUrl into its baseConfig headers, matching the createOpenRouter() behavior. Previously these options were silently ignored through the deprecated path.

Key details for review

  • appName maps to X-OpenRouter-Title, appUrl maps to HTTP-Referer — these are the canonical headers per OpenRouter app attribution docs.
  • Header precedence: appName/appUrl are spread before options.headers in both createOpenRouter() and the deprecated OpenRouter class, so explicit headers entries take priority. This is covered by a dedicated test for createOpenRouter().
  • Falsy values (empty string, undefined) are not set as headers due to the && guard.

Items for human review

  • The changeset file references X-Title — Fixed: changeset now correctly references X-OpenRouter-Title.
  • The deprecated OpenRouter class in facade.ts silently ignores appName/appUrl — Fixed: facade.ts now stores and wires both options into headers.
  • No dedicated unit tests for the deprecated OpenRouter facade class with appName/appUrl — the 5 existing tests cover createOpenRouter() only. The facade wiring uses the same spread pattern, but has no test coverage.
  • The Speakeasy-generated @openrouter/sdk still uses the legacy X-Title header name. This PR intentionally uses the current canonical X-OpenRouter-Title per OpenRouter docs — be aware of the difference across SDKs.
  • No end-to-end testing against the live OpenRouter API was performed — only unit tests with a mock server. Headers are verified via test server request inspection.

Changes

  • src/provider.ts: Added appName and appUrl to OpenRouterProviderSettings interface; wired into getHeaders() as X-OpenRouter-Title and HTTP-Referer respectively.
  • src/facade.ts: Wired appName and appUrl into the deprecated OpenRouter class constructor and baseConfig headers, matching createOpenRouter() 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

  • I have run pnpm stylecheck and pnpm typecheck
  • I have run pnpm test and all tests pass (248/248)
  • I have added tests for my changes (5 new tests)
  • I have updated documentation (if applicable) — README update may be desired as a follow-up

Changeset

  • I have run pnpm changeset to create a changeset file (minor)

Link to Devin session: https://app.devin.ai/sessions/a4b5cbff5a0448aa89aa45557aa32161
Requested by: @robert-j-y

Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
@robert-j-y robert-j-y requested a review from mattapperson March 4, 2026 00:24
devin-ai-integration bot and others added 3 commits March 4, 2026 20:47
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>
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