fix(coding-agent): allow model-level baseUrl override in models.json closes #1777
This commit is contained in:
@@ -237,6 +237,43 @@ describe("ModelRegistry", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("model-level baseUrl overrides provider-level baseUrl for custom models", () => {
|
||||
writeRawModelsJson({
|
||||
"opencode-go": {
|
||||
baseUrl: "https://opencode.ai/zen/go/v1",
|
||||
apiKey: "TEST_KEY",
|
||||
models: [
|
||||
{
|
||||
id: "minimax-m2.5",
|
||||
api: "anthropic-messages",
|
||||
baseUrl: "https://opencode.ai/zen/go",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: { input: 0.3, output: 1.2, cacheRead: 0.03, cacheWrite: 0 },
|
||||
contextWindow: 204800,
|
||||
maxTokens: 131072,
|
||||
},
|
||||
{
|
||||
id: "glm-5",
|
||||
api: "openai-completions",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: { input: 1, output: 3.2, cacheRead: 0.2, cacheWrite: 0 },
|
||||
contextWindow: 204800,
|
||||
maxTokens: 131072,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const registry = new ModelRegistry(authStorage, modelsJsonPath);
|
||||
const m25 = registry.find("opencode-go", "minimax-m2.5");
|
||||
const glm5 = registry.find("opencode-go", "glm-5");
|
||||
|
||||
expect(m25?.baseUrl).toBe("https://opencode.ai/zen/go");
|
||||
expect(glm5?.baseUrl).toBe("https://opencode.ai/zen/go/v1");
|
||||
});
|
||||
|
||||
test("modelOverrides still apply when provider also defines models", () => {
|
||||
writeRawModelsJson({
|
||||
openrouter: {
|
||||
|
||||
Reference in New Issue
Block a user