feat(openrouter): send HTTP-Referer and X-Title headers to identify app#11857
feat(openrouter): send HTTP-Referer and X-Title headers to identify app#11857
Conversation
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
|
Docs Review: No documentation updates needed for this PR. This change automatically sends |
Test Coverage ReviewThis PR adds new functionality for sending Missing Test CoverageThe following new functionality should have tests:
Suggested Test Casesdescribe('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 |
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.
Summary
HTTP-Referer: https://www.continue.dev/andX-Title: Continueheaders to all OpenRouter API requests, per the OpenRouter docsrequestOptions.headerstake precedence over the defaultsCloses #4049
Test plan
HTTP-RefererandX-TitleheadersrequestOptions.headerscan still override these defaultsSummary by cubic
Send
HTTP-Referer: https://www.continue.dev/andX-Title: Continuewith all OpenRouter API requests to identify the app in OpenRouter’s dashboard and App Showcase. Headers are injected viarequestOptions.headersso they apply to all requests; user-provided headers still override, and the redundantgetHeaders()override was removed.Written for commit 2945159. Summary will update on new commits.