fix: add deepseek- dash-prefix routing to UPSTREAM_ROUTES#406
Merged
Conversation
Contributor
rgutzen
commented
May 19, 2026
- Add { prefix: 'deepseek-', url: 'https://api.deepseek.com', protocol: 'openai' } to UPSTREAM_ROUTES in config.ts for direct DeepSeek API access
- Models like deepseek-v4-pro now correctly route to api.deepseek.com instead of falling back to OpenAI with a DeepSeek API key (401 error)
- Add upstream-routes.test.ts with 16 tests covering all route prefixes including DeepSeek dash-prefix (deepseek-v4-pro, deepseek-chat) and slash-prefix (deepseek/deepseek-r1 to Nvidia NIM)
- Add { prefix: 'deepseek-', url: 'https://api.deepseek.com', protocol: 'openai' }
to UPSTREAM_ROUTES in config.ts for direct DeepSeek API access
- Models like deepseek-v4-pro now correctly route to api.deepseek.com
instead of falling back to OpenAI with a DeepSeek API key (401 error)
- Add upstream-routes.test.ts with 16 tests covering all route prefixes
including DeepSeek dash-prefix (deepseek-v4-pro, deepseek-chat) and
slash-prefix (deepseek/deepseek-r1 to Nvidia NIM)
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds DeepSeek “dash-prefix” (deepseek-…) model routing to the gateway’s upstream resolver and introduces a Bun test suite to validate routing behavior across providers.
Changes:
- Added a new
UPSTREAM_ROUTESentry routingdeepseek-models tohttps://api.deepseek.com. - Added
resolveUpstreamRouteunit tests covering multiple providers, DeepSeek variants, Nvidia NIM slash-prefix routes, and unknown-model behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/gateway/src/config.ts | Adds DeepSeek direct API routing via deepseek- prefix. |
| packages/gateway/test/upstream-routes.test.ts | Introduces unit tests to verify upstream route resolution across model prefixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+102
to
+114
| expect(result!.url).toBe("https://integrate.api.nvidia.com"); | ||
| }); | ||
|
|
||
| test("routes meta/ models to Nvidia NIM", () => { | ||
| const result = resolveUpstreamRoute("meta/llama-4-maverick"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://integrate.api.nvidia.com"); | ||
| }); | ||
|
|
||
| test("routes qwen/ models to Nvidia NIM", () => { | ||
| const result = resolveUpstreamRoute("qwen/qwen3-235b-a22b"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://integrate.api.nvidia.com"); |
Comment on lines
+12
to
+64
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.anthropic.com"); | ||
| expect(result!.protocol).toBe("anthropic"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("OpenAI", () => { | ||
| test("routes gpt- models to OpenAI API", () => { | ||
| const result = resolveUpstreamRoute("gpt-4o"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.openai.com"); | ||
| expect(result!.protocol).toBe("openai"); | ||
| }); | ||
|
|
||
| test("routes o1- models to OpenAI API", () => { | ||
| const result = resolveUpstreamRoute("o1-pro"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.openai.com"); | ||
| expect(result!.protocol).toBe("openai"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("xAI", () => { | ||
| test("routes grok- models to xAI API", () => { | ||
| const result = resolveUpstreamRoute("grok-3-beta"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.x.ai"); | ||
| expect(result!.protocol).toBe("openai"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Mistral (direct)", () => { | ||
| test("routes mistral- models to Mistral API", () => { | ||
| const result = resolveUpstreamRoute("mistral-large-latest"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.mistral.ai"); | ||
| expect(result!.protocol).toBe("openai"); | ||
| }); | ||
|
|
||
| test("routes codestral- models to Mistral API", () => { | ||
| const result = resolveUpstreamRoute("codestral-latest"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://api.mistral.ai"); | ||
| expect(result!.protocol).toBe("openai"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Google (direct)", () => { | ||
| test("routes gemini- models to Google API", () => { | ||
| const result = resolveUpstreamRoute("gemini-2.5-pro"); | ||
| expect(result).not.toBeNull(); | ||
| expect(result!.url).toBe("https://generativelanguage.googleapis.com"); | ||
| expect(result!.protocol).toBe("openai"); |
- Replace result! non-null assertions with toEqual() for safer assertions - Add protocol assertions to Nvidia NIM tests for consistency - Add missing test cases for o3-, o4-, mistralai/, and google/ prefixes - Addresses Copilot review comments
Owner
|
Thanks for the contribution @rgutzen! The DeepSeek dash-prefix route is a great catch — this was a real gap in the routing table. I addressed the Copilot review comments and added a few extra test cases (o3-, o4-, mistralai/, google/ prefixes) while I was at it. Merged! |
This was referenced May 21, 2026
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.