mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:21:23 +00:00
fix(providers): preserve openrouter/ prefix for native models (#12942)
* fix(providers): preserve openrouter/ prefix for native models (#12924) OpenRouter-native models like 'openrouter/aurora-alpha' need the full 'openrouter/<name>' as the model ID in API requests. The existing parseModelRef() stripped the prefix, sending just 'aurora-alpha' which OpenRouter rejects with 400. Fix: normalizeProviderModelId() now re-adds the 'openrouter/' prefix for models without a slash (native models), while passing through external provider models (e.g. 'anthropic/claude-sonnet-4-5') as-is. Closes #12924 * Changelog: add OpenRouter note for #12942 --------- Co-authored-by: Luna AI <luna@coredirection.ai> Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
@@ -83,6 +83,20 @@ describe("model-selection", () => {
|
||||
expect(parseModelRef(" ", "anthropic")).toBeNull();
|
||||
});
|
||||
|
||||
it("should preserve openrouter/ prefix for native models", () => {
|
||||
expect(parseModelRef("openrouter/aurora-alpha", "openai")).toEqual({
|
||||
provider: "openrouter",
|
||||
model: "openrouter/aurora-alpha",
|
||||
});
|
||||
});
|
||||
|
||||
it("should pass through openrouter external provider models as-is", () => {
|
||||
expect(parseModelRef("openrouter/anthropic/claude-sonnet-4-5", "openai")).toEqual({
|
||||
provider: "openrouter",
|
||||
model: "anthropic/claude-sonnet-4-5",
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle invalid slash usage", () => {
|
||||
expect(parseModelRef("/", "anthropic")).toBeNull();
|
||||
expect(parseModelRef("anthropic/", "anthropic")).toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user