Skip to content

feat(openrouter): send HTTP-Referer and X-Title headers to identify app#11857

Merged
RomneyDa merged 2 commits intomainfrom
openrouter-headers
Mar 25, 2026
Merged

feat(openrouter): send HTTP-Referer and X-Title headers to identify app#11857
RomneyDa merged 2 commits intomainfrom
openrouter-headers

Conversation

@RomneyDa
Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa commented Mar 25, 2026

Summary

  • Adds HTTP-Referer: https://www.continue.dev/ and X-Title: Continue headers to all OpenRouter API requests, per the OpenRouter docs
  • This identifies Continue in OpenRouter's activity dashboard and App Showcase
  • User-configured headers in requestOptions.headers take precedence over the defaults

Closes #4049

Test plan

  • Verify OpenRouter requests include HTTP-Referer and X-Title headers
  • Verify user-configured requestOptions.headers can still override these defaults
  • Confirm the OpenRouter activity dashboard shows "Continue" in the App column

Summary by cubic

Send HTTP-Referer: https://www.continue.dev/ and X-Title: Continue with all OpenRouter API requests to identify the app in OpenRouter’s dashboard and App Showcase. Headers are injected via requestOptions.headers so they apply to all requests; user-provided headers still override, and the redundant getHeaders() override was removed.

Written for commit 2945159. Summary will update on new commits.

Adds `HTTP-Referer: https://www.continue.dev/` and `X-Title: Continue`
headers to all OpenRouter API requests, as recommended by the OpenRouter
docs. This lets OpenRouter attribute requests to Continue in their
dashboard and App Showcase.

Headers are injected via both `requestOptions.headers` (for SDK-based
requests) and `getHeaders()` (for direct fetch calls). User-configured
headers take precedence.

Closes #4049
@RomneyDa RomneyDa requested a review from a team as a code owner March 25, 2026 23:34
@RomneyDa RomneyDa requested review from sestinj and removed request for a team March 25, 2026 23:34
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 25, 2026
@continue
Copy link
Copy Markdown
Contributor

continue bot commented Mar 25, 2026

Docs Review: No documentation updates needed for this PR.

This change automatically sends HTTP-Referer and X-Title headers to OpenRouter—an internal implementation detail that happens transparently without user configuration. Since users don't need to configure or be aware of these headers (and can still override them via requestOptions.headers as already documented), no docs changes are required.

@continue
Copy link
Copy Markdown
Contributor

continue bot commented Mar 25, 2026

Test Coverage Review

This PR adds new functionality for sending HTTP-Referer and X-Title headers to OpenRouter, but no tests are included for this behavior.

Missing Test Coverage

The following new functionality should have tests:

  1. getHeaders() override method - Should verify that:

    • The returned headers include HTTP-Referer: https://www.continue.dev/
    • The returned headers include X-Title: Continue
    • Headers from the parent class (super.getHeaders()) are preserved
  2. Constructor header injection - Should verify that:

    • Default OpenRouter headers are added to requestOptions.headers
    • User-provided requestOptions.headers are not overwritten by defaults (user headers take precedence due to spread order)

Suggested Test Cases

describe('OpenRouterApi headers', () => {
  it('includes HTTP-Referer and X-Title in getHeaders', () => {
    const api = new OpenRouterApi({ provider: 'openrouter', apiKey: 'test' });
    const headers = api['getHeaders']();
    expect(headers['HTTP-Referer']).toBe('https://www.continue.dev/');
    expect(headers['X-Title']).toBe('Continue');
  });

  it('allows user headers to override defaults', () => {
    const api = new OpenRouterApi({
      provider: 'openrouter',
      apiKey: 'test',
      requestOptions: {
        headers: { 'X-Title': 'Custom App' }
      }
    });
    // Verify custom header takes precedence
  });
});

Please add tests for the header functionality to packages/openai-adapters/src/apis/OpenRouter.test.ts.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

The OPENROUTER_HEADERS are already injected via requestOptions.headers
in the constructor. Since fetchwithRequestOptions merges
requestOptions.headers into all requests (including direct fetch calls
like fimStream and rerank), the getHeaders() override was redundant.
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 25, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 25, 2026
@RomneyDa RomneyDa merged commit 7968dd1 into main Mar 25, 2026
63 of 66 checks passed
@RomneyDa RomneyDa deleted the openrouter-headers branch March 25, 2026 23:57
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Mar 25, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

OpenRouter: send additional headers to identify app

2 participants