litellm-openai-base-url-namespaced-model-id
Wrote the verified solution to ~/SOLUTION.md.
I located the upstream repo (totalwindupflightsystems/chimera), reproduced the bug, applied the fix, and verified it end to end.
Root cause: In src/chimera/gateway.py, the generic base_url branch of resolve_litellm_model() did api_model = model_name.rsplit("/", 1)[-1], which conflated "strip the one catalog provider prefix" with "take the innermost slash segment." Namespaced upstream ids like router9/ds/deepseek-v4-flash were truncated to deepseek-v4-flash.
Fix: Strip exactly one leading case-insensitive <provider>/ when the catalog id carries it, keeping all inner slashes; otherwise keep the old rsplit fallback.
Verification performed:
- Targeted suite: 37 passed
- RED proof (reverted only gateway.py, kept tests): 10 failed / 27 passed, exactly the namespaced-id assertions ('openai/deepseek-v4-flash' == 'openai/ds/deepseek-v4-flash')
- Restored: 37 passed
- Full suite: 1041 passed, 64 skipped, 0 failed (context's 1043/62 delta is local optional-dep skips)
- Direct resolution table confirmed: router9/ds/deepseek-v4-flash → openai/ds/deepseek-v4-flash, router9/openrouter/x-ai/grok-4.6 → openai/openrouter/x-ai/grok-4.6, hermes/glm-5.3-flash → openai/glm-5.3-flash (regression guard), and the non-prefixed fallback still resolves to the last segment.
The markdown is self-contained with the root-cause analysis, exact diff, test/verification commands, and generalization notes.
# Evidence - Problem class: litellm-openai-base-url-namespaced-model-id - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-17T16:56:16.358Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "SYMPTOM: a Chimera provider whose upstream model ids are themselves namespaced (9router: ds/deepseek-v4-flash, openrouter/x-ai/grok-4.6) could not be called through the generic OpenAI-compatible branch that routes on providers.<name>.base_url. The branch derived the upstream model id as model_name.rsplit('/', 1)[-1], i.e. it assumed the catalog id <provider>/<model> has exactly ONE slash. For router9/ds/deepseek-v4-flash that produced 'deepseek-v4-flash', so the request went upstream with a model id the gateway does not serve.", "environment": "chimera-deliberation (LiteLLM gateway), 9router central gateway http://master001:20128/v1", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "litellm-openai-base-url-namespaced-model-id", "provider": "openrouter", "solved_at": "2026-09-17T16:56:16.358Z", "version": "chimera-deliberation 0.2.6 (work commit 4c4c6f0, INT-PROV-ROUTER9-001)"}Wrote the verified solution to ~/SOLUTION.md.
I located the upstream repo (totalwindupflightsystems/chimera), reproduced the bug, applied the fix, and verified it end to end.
Root cause: In src/chimera/gateway.py, the generic base_url branch of resolve_litellm_model() did api_model = model_name.rsplit("/", 1)[-1], which conflated "strip the one catalog provider prefix" with "take the innermost slash segment." Namespaced upstream ids like router9/ds/deepseek-v4-flash were truncated to deepseek-v4-flash.
Fix: Strip exactly one leading case-insensitive <provider>/ when the catalog id carries it, keeping all inner slashes; otherwise keep the old rsplit fallback.
Verification performed:
- Targeted suite: 37 passed
- RED proof (reverted only gateway.py, kept tests): 10 failed / 27 passed, exactly the namespaced-id assertions ('openai/deepseek-v4-flash' == 'openai/ds/deepseek-v4-flash')
- Restored: 37 passed
- Full suite: 1041 passed, 64 skipped, 0 failed (context's 1043/62 delta is local optional-dep skips)
- Direct resolution table confirmed: router9/ds/deepseek-v4-flash → openai/ds/deepseek-v4-flash, router9/openrouter/x-ai/grok-4.6 → openai/openrouter/x-ai/grok-4.6, hermes/glm-5.3-flash → openai/glm-5.3-flash (regression guard), and the non-prefixed fallback still resolves to the last segment.
The markdown is self-contained with the root-cause analysis, exact diff, test/verification commands, and generalization notes.
# Evidence - Problem class: litellm-openai-base-url-namespaced-model-id - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-17T16:56:16.358Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "SYMPTOM: a Chimera provider whose upstream model ids are themselves namespaced (9router: ds/deepseek-v4-flash, openrouter/x-ai/grok-4.6) could not be called through the generic OpenAI-compatible branch that routes on providers.<name>.base_url. The branch derived the upstream model id as model_name.rsplit('/', 1)[-1], i.e. it assumed the catalog id <provider>/<model> has exactly ONE slash. For router9/ds/deepseek-v4-flash that produced 'deepseek-v4-flash', so the request went upstream with a model id the gateway does not serve.", "environment": "chimera-deliberation (LiteLLM gateway), 9router central gateway http://master001:20128/v1", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "litellm-openai-base-url-namespaced-model-id", "provider": "openrouter", "solved_at": "2026-09-17T16:56:16.358Z", "version": "chimera-deliberation 0.2.6 (work commit 4c4c6f0, INT-PROV-ROUTER9-001)"}