Repository navigation
feat(proxy): show real upstream provider on dashboard for OpenAI-compatible endpoints - #1594
Conversation
…atible endpoints When the proxy runs against a custom OpenAI-compatible endpoint via --openai-api-url (OpenRouter, Groq, Together, Azure OpenAI, …), the dashboard always labelled traffic as 'openai' because the OpenAI handler records every request with provider='openai'. Detect well-known upstreams from the configured --openai-api-url host and add a --provider-name override that takes precedence. The label is resolved only where the dashboard/stats payload is built; the internal provider key stays 'openai' so pricing and request formatting are unchanged. Closes headroomlabs-ai#1533
PR governanceThis PR follows the template and is marked ready for human review. |
JerrettDavis
left a comment
There was a problem hiding this comment.
The provider-label change is scoped to display/stat payloads: internal provider keys remain openai, while dashboard/recent-request/count presentation can resolve --provider-name or known OpenAI-compatible hosts such as OpenRouter/Groq/Together/Azure. That is the right boundary for preserving pricing and request formatting behavior.
I attempted python -m pytest tests/test_provider_display_classification.py -q, but this review worktree cannot collect full proxy imports because headroom._core is not built locally. From direct diff review, I do not see a remaining code-review blocker.
JerrettDavis
left a comment
There was a problem hiding this comment.
Approved current head cfcdf43 after merging current headroomlabs/main and resolving the /stats recent-request payload conflict by preserving current-main token-accounting fields while applying the PR's display-provider remapping.
Validated locally:
uv run --extra dev python -m pytest tests/test_provider_display_classification.py tests/test_dashboard_agent_usage.py tests/test_proxy_stats_recent_requests.py -quvx [email protected] check headroom/proxy/helpers.py headroom/proxy/server.py headroom/proxy/models.py headroom/cli/proxy.py tests/test_provider_display_classification.py tests/test_dashboard_agent_usage.py tests/test_proxy_stats_recent_requests.pyuvx [email protected] format --check headroom/proxy/helpers.py headroom/proxy/server.py headroom/proxy/models.py headroom/cli/proxy.py tests/test_provider_display_classification.py tests/test_dashboard_agent_usage.py tests/test_proxy_stats_recent_requests.pyuvx [email protected] headroom/proxy/helpers.py headroom/proxy/server.py headroom/proxy/models.py headroom/cli/proxy.py --ignore-missing-importsgit diff --check
Description
When the proxy runs against a custom OpenAI-compatible endpoint via
--openai-api-url(OpenRouter, Groq, Together, Azure OpenAI, …), the dashboard always showed the provider as OpenAI, because the OpenAI handler records every request withprovider="openai".This detects well-known upstreams from the
--openai-api-urlhost and adds a--provider-nameoverride that takes precedence (the issue's option 3). The label is resolved only where the dashboard/stats payload is built — the internal provider key staysopenai, so pricing and request formatting are unaffected.https://api.openai.com/v1https://openrouter.ai/api/v1https://api.groq.com/openai/v1https://api.together.xyz/v1https://<resource>.openai.azure.com/Unknown hosts keep the
openailabel unless--provider-nameis set.Closes #1533
Type of Change
Changes Made
helpers.py:classify_openai_upstream()(host → display name) +resolve_display_provider()(precedence:--provider-name> host detection > raw provider; only relabelsopenai).models.py:ProxyConfig.provider_name.cli/proxy.py:--provider-nameflag, threaded intoProxyConfig.server.py: relabel at the four dashboard/stats display sites (recent requests, transformations feed,requests.by_provider, agent-usage breakdown) via the resolver /_remap_provider_counts. Stored logs and metrics keys are untouched.docs/content/docs/proxy.mdx: document--provider-name.Testing
pytest)ruff check)Test Output
Real Behavior Proof
feat/1533-upstream-provider-classify@ HEAD, local.venv(Python 3)python -c "from headroom.proxy.helpers import classify_openai_upstream, resolve_display_provider; print(classify_openai_upstream('https://openrouter.ai/api/v1')); print(resolve_display_provider('openai', openai_api_url='https://openrouter.ai/api/v1')); print(resolve_display_provider('openai', openai_api_url='https://openrouter.ai/api/v1', provider_name='Groq')); print(resolve_display_provider('anthropic'))"openai→OpenRouter,--provider-nameoverrides detection (Groq), and theanthropiclabel (plus theopenaipricing key) is unchanged. Full output below:Review Readiness
Checklist