[GH-ISSUE #287] feat: template variables in request params, e.g. session_id = $CHAT_ID #200

Open
opened 2026-10-18 14:03:45 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @Classic298 on GitHub (Sep 20, 2026).
Original GitHub issue: https://github.com/open-webui/computer/issues/287

What happens

Model-specific request params (Settings → model → request params) merge into the API request body as-is, static values only. That works for things like provider routing, which is what the field is used for in practice.

What's missing is any way to reference per-request context. Concretely: on OpenRouter, session_id in the body pins prompt-cache affinity per conversation (it's also the key OpenRouter derives Z.AI cache affinity from, and the fallback when the OpenAI-style prompt_cache_key is sent instead). Sending it is only useful if the value differs per chat — a static one glues all chats to one cache session.

So today there is no way to tell OpenRouter "this request belongs to chat X" even though the chat id is right there in the request loop.

Suggested change

Template variables in request-param values, resolved at request time:

{ "session_id": "$CHAT_ID" }

$CHAT_ID is enough to cover the cache-affinity case on OpenRouter (and prompt_cache_key for OpenAI-compatible endpoints with the same mechanism). The chat id is available where params are merged in the request loop, so this is a small substitution at merge time, not new plumbing.

Bonus, same mechanism: $MODEL_ID, $WORKSPACE if there's ever a need.

Originally created by @Classic298 on GitHub (Sep 20, 2026). Original GitHub issue: https://github.com/open-webui/computer/issues/287 ## What happens Model-specific request params (Settings → model → request params) merge into the API request body as-is, static values only. That works for things like `provider` routing, which is what the field is used for in practice. What's missing is any way to reference per-request context. Concretely: on OpenRouter, `session_id` in the body pins prompt-cache affinity per conversation (it's also the key OpenRouter derives Z.AI cache affinity from, and the fallback when the OpenAI-style `prompt_cache_key` is sent instead). Sending it is only useful if the value differs per chat — a static one glues all chats to one cache session. So today there is no way to tell OpenRouter "this request belongs to chat X" even though the chat id is right there in the request loop. ## Suggested change Template variables in request-param values, resolved at request time: ```json { "session_id": "$CHAT_ID" } ``` `$CHAT_ID` is enough to cover the cache-affinity case on OpenRouter (and `prompt_cache_key` for OpenAI-compatible endpoints with the same mechanism). The chat id is available where params are merged in the request loop, so this is a small substitution at merge time, not new plumbing. Bonus, same mechanism: `$MODEL_ID`, `$WORKSPACE` if there's ever a need.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/computer#200
No description provided.