fix: normalize OpenAI-compatible paths with arbitrary prefixes#108
Merged
Conversation
commit: |
jpr5
force-pushed
the
fix/compat-path-prefix
branch
9 times, most recently
from
April 13, 2026 17:43
1023040 to
de1253b
Compare
Providers like BigModel (/v4/chat/completions), DeepSeek, and others use non-standard base URLs. Normalize any path ending in a known endpoint suffix to /v1/<endpoint> before routing. Closes #107
jpr5
force-pushed
the
fix/compat-path-prefix
branch
from
April 13, 2026 17:45
de1253b to
daed83d
Compare
jpr5
added a commit
that referenced
this pull request
Jul 15, 2026
## Summary Fixes #107 — BigModel and other OpenAI-compatible providers use non-standard base URLs (e.g., `/v4/chat/completions`, `/api/coding/paas/v4/chat/completions`). aimock now normalizes any path ending in a known endpoint suffix to `/v1/<endpoint>`. ### What changed - Extracted `normalizeCompatPath()` shared function — strips `/openai/` prefix and rewrites arbitrary path prefixes to `/v1/` - Applied in both HTTP handler and WebSocket upgrade handler - Guards: skips `/v1/` (already standard) and `/v2/` (Cohere convention) - Mounts always dispatched before normalization (both HTTP and WS) - Azure deployment paths excluded via `!azureDeploymentId` guard - Metrics record the normalized path via closure - Debug logging when normalization fires ### Supported suffixes `/chat/completions`, `/embeddings`, `/responses`, `/audio/speech`, `/audio/transcriptions`, `/images/generations` ## Test plan - [x] 12 HTTP normalization tests (all 6 suffixes, /v1/ regression, /v2/ guard, /openai/ combo, negative 404) - [x] 3 WebSocket normalization tests (/custom/responses, /openai/ strip, /v2/ guard) - [x] All 2320 tests pass - [x] Build passes - [x] 4-round CR loop with 7 agents per round 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #107 — BigModel and other OpenAI-compatible providers use non-standard base URLs (e.g.,
/v4/chat/completions,/api/coding/paas/v4/chat/completions). aimock now normalizes any path ending in a known endpoint suffix to/v1/<endpoint>.What changed
normalizeCompatPath()shared function — strips/openai/prefix and rewrites arbitrary path prefixes to/v1//v1/(already standard) and/v2/(Cohere convention)!azureDeploymentIdguardSupported suffixes
/chat/completions,/embeddings,/responses,/audio/speech,/audio/transcriptions,/images/generationsTest plan
🤖 Generated with Claude Code