Skip to content

Commit ba7f69a

Browse files
committed
feat: add image support for moonshotai/kimi-k2:free model
- Add OPEN_ROUTER_IMAGE_SUPPORT_MODELS set to handle models with image support not correctly reported by OpenRouter API - Update parseOpenRouterModel to check hardcoded image support models - Add test coverage for image support functionality Fixes #5877
1 parent 38d8edf commit ba7f69a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

packages/types/src/providers/openrouter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ export const OPEN_ROUTER_REASONING_BUDGET_MODELS = new Set([
8888
"anthropic/claude-3.7-sonnet:thinking",
8989
"google/gemini-2.5-flash-preview-05-20:thinking",
9090
])
91+
92+
// Models that support image input but may not be correctly reported by OpenRouter API
93+
export const OPEN_ROUTER_IMAGE_SUPPORT_MODELS = new Set([
94+
"moonshotai/kimi-k2:free",
95+
])

src/api/providers/fetchers/__tests__/openrouter.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
OPEN_ROUTER_COMPUTER_USE_MODELS,
1010
OPEN_ROUTER_REASONING_BUDGET_MODELS,
1111
OPEN_ROUTER_REQUIRED_REASONING_BUDGET_MODELS,
12+
OPEN_ROUTER_IMAGE_SUPPORT_MODELS,
1213
} from "@roo-code/types"
1314

1415
import { getOpenRouterModelEndpoints, getOpenRouterModels } from "../openrouter"
@@ -148,6 +149,15 @@ describe("OpenRouter API", () => {
148149
.sort(),
149150
).toEqual(expectedRequiredReasoningBudgetModels)
150151

152+
// Test image support for hardcoded models
153+
expect(
154+
Object.entries(models)
155+
.filter(([_, model]) => model.supportsImages)
156+
.map(([id, _]) => id)
157+
.filter((id) => OPEN_ROUTER_IMAGE_SUPPORT_MODELS.has(id))
158+
.sort(),
159+
).toEqual(Array.from(OPEN_ROUTER_IMAGE_SUPPORT_MODELS).sort())
160+
151161
expect(models["anthropic/claude-3.7-sonnet"]).toEqual({
152162
maxTokens: 8192,
153163
contextWindow: 200000,

src/api/providers/fetchers/openrouter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
OPEN_ROUTER_COMPUTER_USE_MODELS,
88
OPEN_ROUTER_REASONING_BUDGET_MODELS,
99
OPEN_ROUTER_REQUIRED_REASONING_BUDGET_MODELS,
10+
OPEN_ROUTER_IMAGE_SUPPORT_MODELS,
1011
anthropicModels,
1112
} from "@roo-code/types"
1213

@@ -193,7 +194,7 @@ export const parseOpenRouterModel = ({
193194
const modelInfo: ModelInfo = {
194195
maxTokens: maxTokens || Math.ceil(model.context_length * 0.2),
195196
contextWindow: model.context_length,
196-
supportsImages: modality?.includes("image") ?? false,
197+
supportsImages: modality?.includes("image") ?? OPEN_ROUTER_IMAGE_SUPPORT_MODELS.has(id) ?? false,
197198
supportsPromptCache,
198199
inputPrice: parseApiPrice(model.pricing?.prompt),
199200
outputPrice: parseApiPrice(model.pricing?.completion),

0 commit comments

Comments
 (0)