Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(cli): label savings cost bars with the auto-router name

Tin Chi Lobebc76316cd8
diff --git a/litellm/proxy/client/cli/commands/statusline_script.py b/litellm/proxy/client/cli/commands/statusline_script.py
index 5493586f627..0e1c1b25e0f 100644
--- a/litellm/proxy/client/cli/commands/statusline_script.py
+++ b/litellm/proxy/client/cli/commands/statusline_script.py
@@ -50,7 +50,6 @@ CODEX_BASE_URL_ENV_KEYS: Final = ("OPENAI_BASE_URL",)
CODEX_API_KEY_ENV_KEYS: Final = ("OPENAI_API_KEY",)
CODEX_STOP_EVENT: Final = "Stop"
SYNTHETIC_MODEL: Final = "<synthetic>"
-LITELLM_LABEL: Final = "LiteLLM"
RESET: Final = "\033[0m"
BOLD: Final = "\033[1m"
DIM: Final = "\033[90m"
@@ -316,9 +315,9 @@ def render(model: str, session: Session | None, config_dir: Path, use_color: boo
pct: Final = (session.baseline_spend - session.spend) / session.baseline_spend * 100
delta: Final = paint(LITELLM_COLOR, f"{'-' if pct >= 0 else '+'}{abs(round(pct))}% vs {reference}")
peak: Final = max(session.spend, session.baseline_spend)
- label_width: Final = max(len(LITELLM_LABEL), len(reference))
+ label_width: Final = max(len(session.router_name), len(reference))
rows: Final = (
- (LITELLM_LABEL, session.spend, LITELLM_COLOR),
+ (session.router_name, session.spend, LITELLM_COLOR),
(reference, session.baseline_spend, BASELINE_COLOR),
)
lines: Final = (
diff --git a/tests/test_litellm/proxy/client/cli/test_statusline_script.py b/tests/test_litellm/proxy/client/cli/test_statusline_script.py
index 5c0cf6b5703..2b812932542 100644
--- a/tests/test_litellm/proxy/client/cli/test_statusline_script.py
+++ b/tests/test_litellm/proxy/client/cli/test_statusline_script.py
@@ -253,10 +253,18 @@ class TestRender:
text = render("claude-sonnet-5", RECORDED, config_dir, use_color=False, bar_width=10)
assert text.splitlines() == [
"claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5",
- "LiteLLM ████░░░░░░ $0.14",
+ "claude-auto ████░░░░░░ $0.14",
"Claude Opus 5 ██████████ $0.38",
]
+ def test_a_long_router_name_keeps_both_cost_bars_aligned(self, config_dir: Path) -> None:
+ session: Final = RECORDED._replace(router_name="engineering-smart-router")
+ text: Final = render("claude-sonnet-5", session, config_dir, use_color=False, bar_width=10)
+ assert text.splitlines()[1:] == [
+ "engineering-smart-router ████░░░░░░ $0.14",
+ "Claude Opus 5 ██████████ $0.38",
+ ]
+
def test_control_characters_in_any_externally_sourced_label_never_reach_the_terminal(self, tmp_path, config_dir):
# The transcript, the proxy payload and Claude Code's model cache all feed labels straight into a
# terminal, and none is under this script's control. Only the control bytes are dropped (ESC, BEL,
@@ -312,6 +320,7 @@ class TestClaudeCodeMode:
text: Final = _run(_payload(transcript), _env(tmp_path, config_dir), fetch)
assert text.startswith("claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5\n")
+ assert text.splitlines()[1].startswith("claude-auto ")
def test_a_discovered_display_name_labels_the_sessions_model(
self, tmp_path: Path, transcript: Path, config_dir: Path
@@ -379,6 +388,7 @@ class TestCodexMode:
out = _run({"hook_event_name": "Stop", "session_id": SESSION_ID, "transcript_path": "/nope"}, env, fetch)
message = json.loads(out)["systemMessage"]
assert message.splitlines()[1] == "claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5"
+ assert message.splitlines()[2].startswith("claude-auto ")
assert message.startswith("\n")
assert seen == [Credentials("http://127.0.0.1:4000", "sk-codex")]