[Feature request]: set HTTP-Referer header to help openrouter detect App #1871

Closed
opened 2026-02-16 17:33:01 -05:00 by yindo · 2 comments
Owner

Originally created by @geril07 on GitHub (Sep 28, 2025).

Originally assigned to: @rekram1-node on GitHub.

Currently, when using openrouter, in Activity page requests have no App name(Unknown), this can be changed by setting HTTP-Referer header
You can check it the openrouter docs

(First two rows were made from "dirty" app with the proposed change)
Image

Proposed change(it could be wrapped into if is openrouter, im not sure if it's openrouter specific):

diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 6ebae33..b32cfd7 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -263,7 +263,7 @@ export namespace SessionPrompt {
                 "x-opencode-session": input.sessionID,
                 "x-opencode-request": userMsg.info.id,
               }
-            : undefined,
+            : { "HTTP-Referer": "https://opencode.ai" },
         maxRetries: 10,
         activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
         maxOutputTokens: ProviderTransform.maxOutputTokens(model.providerID, outputLimit, params.options),

And that's also can be added to ensureTitle and others

Originally created by @geril07 on GitHub (Sep 28, 2025). Originally assigned to: @rekram1-node on GitHub. Currently, when using openrouter, in Activity page requests have no App name(Unknown), this can be changed by setting `HTTP-Referer` header You can check it the openrouter [docs](https://openrouter.ai/docs/api-reference/overview#headers) (First two rows were made from "dirty" app with the proposed change) <img width="1384" height="331" alt="Image" src="https://github.com/user-attachments/assets/065dd0ac-90b9-464a-a0c5-f81703bc1ce7" /> Proposed change(it could be wrapped into if is openrouter, im not sure if it's openrouter specific): ```patch diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 6ebae33..b32cfd7 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -263,7 +263,7 @@ export namespace SessionPrompt { "x-opencode-session": input.sessionID, "x-opencode-request": userMsg.info.id, } - : undefined, + : { "HTTP-Referer": "https://opencode.ai" }, maxRetries: 10, activeTools: Object.keys(tools).filter((x) => x !== "invalid"), maxOutputTokens: ProviderTransform.maxOutputTokens(model.providerID, outputLimit, params.options), ``` And that's also can be added to `ensureTitle` and others
yindo closed this issue 2026-02-16 17:33:01 -05:00
Author
Owner

@rekram1-node commented on GitHub (Sep 28, 2025):

@geril07 what version of opencode are you using? I think opencode is already properly detected...

Usage Example:

Image

Openrouter leaderboard example:
Image

@rekram1-node commented on GitHub (Sep 28, 2025): @geril07 what version of opencode are you using? I think opencode is already properly detected... Usage Example: <img width="1285" height="306" alt="Image" src="https://github.com/user-attachments/assets/250bab72-9b5b-404a-a0d0-c059714d26d0" /> Openrouter leaderboard example: <img width="1156" height="447" alt="Image" src="https://github.com/user-attachments/assets/0cffe971-63b8-4eae-9ca4-a2a1e00e5baf" />
Author
Owner

@geril07 commented on GitHub (Sep 29, 2025):

Yep, you are right. I guess it was 0.12.1, sorry about that.

@geril07 commented on GitHub (Sep 29, 2025): Yep, you are right. I guess it was 0.12.1, sorry about that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1871