From 83c543a0baa4d7095d127de983cb2c5e79458b68 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Sat, 31 Oct 2026 21:26:03 +0000 Subject: [PATCH] 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. --- .../patch_expose_cost_headers.cpython-314.pyc | Bin 3951 -> 4172 bytes patch_expose_cost_headers.py | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/__pycache__/patch_expose_cost_headers.cpython-314.pyc b/__pycache__/patch_expose_cost_headers.cpython-314.pyc index 4558d99a80a38ce242ae60d322d161edc3157b98..7fac41fb781c1661745199816c28cceeb2722ff5 100644 GIT binary patch delta 396 zcmaDacSeCvn~#@^0SJ!7Jjj7qH?>L-A)1_+lcSrNQYDNK%1*7+EiOpSOR16rnj~DGQd*Q)l9`{Un_FBZ zhftPZmRgjNnwX-CLmp&uQetv8io7&Je_}~VYHmSEYKm@AYDrOMYH^h;Hpw&&s5!-x z`}mqQ#D$p}_&*piu$wn9e_&x`6?nkL(VpIzei0O;mwBx(vsr&-Wn#6NY{_p104DT_ AOaK4? delta 187 zcmX@3@LrBjn~#@^0SF9~pJlz^*~sU|u4oM87E1z&mkbRI7kDjJ+AK(%z&S&4hVTrR zt9**9Z6?>U_cK~-=H9PR0i=@&sRxXf#Dna$!WD-)~bWHA9V0Ne&Se*gdg diff --git a/patch_expose_cost_headers.py b/patch_expose_cost_headers.py index be6e078..72f9bc1 100644 --- a/patch_expose_cost_headers.py +++ b/patch_expose_cost_headers.py @@ -29,7 +29,7 @@ import sys # 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. -COST_HEADERS = [ +EXPOSED_HEADERS = [ "x-litellm-response-cost", "x-litellm-response-cost-input", "x-litellm-response-cost-output", @@ -42,13 +42,23 @@ COST_HEADERS = [ "x-litellm-response-cost-reasoning", "x-litellm-response-cost-tool-usage", "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" NEW = ( " expose_headers=LITELLM_UI_ALLOW_HEADERS\n" " + [\n" - + "".join(f' "{h}",\n' for h in COST_HEADERS) + + "".join(f' "{h}",\n' for h in EXPOSED_HEADERS) + " ],\n" ) @@ -72,7 +82,7 @@ def main() -> int: return 0 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