gateway: expose the eight telemetry headers requested in co-op/support#39

Adds x-litellm-model-name, -call-id, -key-spend, -response-duration-ms, -overhead-duration-ms, -callback-duration-ms, -attempted-retries and -attempted-fallbacks to the CORS expose list, on the GM's go-ahead. Renames COST_HEADERS to EXPOSED_HEADERS since the list is no longer only costs. x-litellm-key-spend discloses the caller's own key spend, which is their own data; noted in the thread so it can be dropped if anyone objects.
This commit is contained in:
inference-bot committed 2026-10-31 21:26:03 +00:00
1 parent 197abce9e6
commit 83c543a0ba
2 files changed
+13 -3

No files matched your search

+13 -3
View File
@@ -29,7 +29,7 @@ import sys
# The header names the proxy can set, taken from the running image rather than # The header names the proxy can set, taken from the running image rather than
# guessed: grep -rhoE 'x-litellm-[a-z0-9-]*cost[a-z0-9-]*' over the litellm package. # guessed: grep -rhoE 'x-litellm-[a-z0-9-]*cost[a-z0-9-]*' over the litellm package.
COST_HEADERS = [ EXPOSED_HEADERS = [
"x-litellm-response-cost", "x-litellm-response-cost",
"x-litellm-response-cost-input", "x-litellm-response-cost-input",
"x-litellm-response-cost-output", "x-litellm-response-cost-output",
@@ -42,13 +42,23 @@ COST_HEADERS = [
"x-litellm-response-cost-reasoning", "x-litellm-response-cost-reasoning",
"x-litellm-response-cost-tool-usage", "x-litellm-response-cost-tool-usage",
"x-litellm-classifier-cost", "x-litellm-classifier-cost",
# Telemetry names, requested in co-op/support#39 (2026-10-31): model identity,
# call id, the caller's own key spend, timings and retry/fallback counts.
"x-litellm-model-name",
"x-litellm-call-id",
"x-litellm-key-spend",
"x-litellm-response-duration-ms",
"x-litellm-overhead-duration-ms",
"x-litellm-callback-duration-ms",
"x-litellm-attempted-retries",
"x-litellm-attempted-fallbacks",
] ]
OLD = " expose_headers=LITELLM_UI_ALLOW_HEADERS,\n" OLD = " expose_headers=LITELLM_UI_ALLOW_HEADERS,\n"
NEW = ( NEW = (
" expose_headers=LITELLM_UI_ALLOW_HEADERS\n" " expose_headers=LITELLM_UI_ALLOW_HEADERS\n"
" + [\n" " + [\n"
+ "".join(f' "{h}",\n' for h in COST_HEADERS) + "".join(f' "{h}",\n' for h in EXPOSED_HEADERS)
+ " ],\n" + " ],\n"
) )
@@ -72,7 +82,7 @@ def main() -> int:
return 0 return 0
target.write_text(src.replace(OLD, NEW)) target.write_text(src.replace(OLD, NEW))
print(f"expose-cost-headers: appended {len(COST_HEADERS)} cost header names to expose_headers in {target}") print(f"expose-cost-headers: appended {len(EXPOSED_HEADERS)} cost header names to expose_headers in {target}")
return 0 return 0