Skip to content

fix: normalize OpenAI-compatible paths with arbitrary prefixes#108

Open
jpr5 wants to merge 1 commit intomainfrom
fix/compat-path-prefix
Open

fix: normalize OpenAI-compatible paths with arbitrary prefixes#108
jpr5 wants to merge 1 commit intomainfrom
fix/compat-path-prefix

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented Apr 13, 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

  • 12 HTTP normalization tests (all 6 suffixes, /v1/ regression, /v2/ guard, /openai/ combo, negative 404)
  • 3 WebSocket normalization tests (/custom/responses, /openai/ strip, /v2/ guard)
  • All 2320 tests pass
  • Build passes
  • 4-round CR loop with 7 agents per round

🤖 Generated with Claude Code

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@108

commit: daed83d

@jpr5 jpr5 force-pushed the fix/compat-path-prefix branch 9 times, most recently from 1023040 to de1253b Compare April 13, 2026 17:43
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 jpr5 force-pushed the fix/compat-path-prefix branch from de1253b to daed83d Compare April 13, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigmodel openai

1 participant