Repository navigation
Description
I would like VS Code / GitHub Copilot BYOK model configuration to support either custom static request headers for OpenAI-compatible providers, or a stable per-chat session identifier that is sent with every request in the same chat session.
Background
I am using locally deployed OpenAI-compatible models with BYOK in both VS Code and VS Code Insiders. In my setup, the local inference server is backed by vLLM, and request-level metadata can be useful for cache management, routing, and session-aware behavior.
For example, when using vLLM or a proxy in front of it, I can enable more effective cache usage by sending stable headers such as a tenant/session/cache key header. Some other extensions that support custom OpenAI-compatible providers already allow this. For example, Kilo Code lets users configure custom headers when adding a custom OpenAI-compatible provider.
When I inspected the requests sent by Copilot, I could see request/completion identifiers that change per prompt, but I could not find a stable value that remains the same for all prompts in the same chat window/session. This makes it difficult for local providers or proxies to associate related requests with the same chat session for caching or routing purposes.
Proposed solution
It would be helpful if VS Code supported one or both of the following for BYOK/OpenAI-compatible providers:
-
Allow users to configure custom static headers per model/provider.
Example:
{ "X-Cache-Key": "my-local-vscode-model", "X-Provider-Mode": "local" } -
Automatically generate and send a stable chat/session identifier for each chat window or conversation.
X-VSCode-Chat-Session-Id: <stable-id-for-this-chat>This value would remain stable for all prompts in the same chat session, but change for a new chat session.
Why this would be useful
This would make BYOK more practical for local and self-hosted model deployments, especially when the provider or proxy needs stable metadata for:
- prompt/prefix cache management
- vLLM-backed local deployments
- request routing
- per-session observability
- debugging local provider behavior
- integrating OpenAI-compatible proxies that support custom headers
Since VS Code appears to be investing more in BYOK and custom model provider support, this would make the feature more flexible for local/self-hosted model users without requiring provider-specific hardcoding.
Existing behavior in other tools
Some extensions already support this kind of configuration. For example, Kilo Code allows custom headers when configuring a custom OpenAI-compatible provider. A similar capability in VS Code's native BYOK support would be very useful.
Alternatives considered
A provider-side proxy can sometimes infer or generate its own session keys, but without a stable identifier from the client, it cannot reliably group requests from the same chat session. Per-request completion IDs are not enough for this use case because they change with every prompt.
Kilo Code Implementation

Activity
albayrakonur commentedon May 18, 2026
I re-examined the headers sent by Copilot Chat requests and noticed the following: it always sends a header named cookie, but within the same chat window, this value may not remain constant.
cookie: 0e31969188bd30aee89be6c9340fab86=f531a50b5863e68d3d3470b3ab2b347bVritant Bhardwaj (@vritant24) This might be useful for you.
CezaryKlus commentedon Jul 9, 2026
My use case is actually to support a stable session identifier as a variable to be used in
chatLanguageModels.jsonContext: Fireworks AI models via Custom Endpoint and prompt caching
https://docs.fireworks.ai/guides/prompt-caching#optimizing-inference-request-for-caching
I would like to specify this:
brenwhyte commentedon Jul 23, 2026
PortKey user here and we need to be able to set
x-portkey-api-keyheader to auth to the Gateway.albayrakonur commentedon Aug 4, 2026
you can user requestHeaders parameters inside customendpoint definition. see https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-custom-endpoint-model
albayrakonur commentedon Aug 4, 2026
Vritant Bhardwaj (@vritant24) if you should provide each chat session has unique session-id value , it will be good for session based api usage stats.
copilot: add language model request middleware API
BIT-Orange commentedon Sep 24, 2026
+1 on the stable-session-identifier variable — and it is worth noting that without it a whole class of gateways simply cannot be configured, because
requestHeadersvalues are static today.Concrete case: OpenCode Go requires a session header on every inference request and rejects the request otherwise (
400 MissingSessionID, tracked in #334186). The only user-side way to satisfy it now is to hardcode one UUID per model:which makes every conversation on that model share one affinity/prompt-cache bucket — the opposite of what the header is for. (The other dynamic token that exists is
${apiKey}inCustomEndpointOAIEndpoint._interpolateApiKey(),extensions/copilot/src/extension/byok/vscode-node/customEndpointProvider.ts:315.)Proposed shape
Support
${sessionId}(name TBD) inrequestHeadersvalues, exactly as Cezary Klus (@CezaryKlus) sketched:Semantics I'd suggest:
_customHeadersis computed once in theOpenAIEndpointconstructor,extensions/copilot/src/extension/byok/node/openAIEndpoint.ts:141, andgetExtraHeaders()at:408takes no context);Where the value can come from: the chat session identity, or — equivalent for routing and prompt-cache grouping — a memoized hash of the conversation's first user message. The community provider extensions that exist purely to add this one header (ltmoerdani/opencode-copilot-chat, OnesoftQwQ/opencode-go-copilot-provider) implement the latter, which shows the behaviour is achievable inside the current provider API without new core plumbing.
A token is preferable to hardcoding a provider-specific header, but if the VS Code team prefers a single built-in contract, an opt-in setting that always sends
x-vscode-chat-session-id: <stable-id>on BYOK requests would solve the same problem in one shot — providers that recognise it (OpenCode already recognises other clients' native session headers) get it for free, at the cost of needing per-gateway adoption.PawelWos1987 commentedon Nov 17, 2026
+1 on the stable-session-identifier variable