fix(image): fall back to text when configured OpenRouter input list is empty

When a model has an explicitly configured but empty input array,
the filter returns an empty array, leaving the model with no supported
modalities. Apply the same empty-array guard used by the non-OpenRouter
fallback path, defaulting to ["text"] when the filtered result is empty.
This commit is contained in:
Jerry-Xin 2026-03-16 16:07:26 +08:00
parent e39a8515f2
commit 2ce93382dd

View File

@ -317,11 +317,15 @@ export function resolveModelWithRegistry(params: {
const configuredOpenRouterModel = providerConfig?.models?.find(
(candidate) => candidate.id === modelId,
);
const resolvedInput: Array<"text" | "image"> = configuredOpenRouterModel?.input
const configuredInput = configuredOpenRouterModel?.input
? configuredOpenRouterModel.input.filter((item) => item === "text" || item === "image")
: isLikelyVisionModel(modelId)
? ["text", "image"]
: ["text"];
: undefined;
const resolvedInput: Array<"text" | "image"> =
configuredInput && configuredInput.length > 0
? configuredInput
: isLikelyVisionModel(modelId)
? ["text", "image"]
: ["text"];
const providerHeaders = sanitizeModelHeaders(providerConfig?.headers, {
stripSecretRefMarkers: true,