From f2e7da85147cc2fa925dca50aac4806234cfaf8c Mon Sep 17 00:00:00 2001 From: shrimbly Date: Tue, 31 Mar 2026 13:06:20 +1300 Subject: [PATCH] fix: check audio inputs before image inputs in schema extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isImageInput() has permissive description heuristics (e.g. "data uri") that false-positive on audio properties like audio_url whose description mentions "base64 data URI". Reorder the checks so isAudioInput() — which uses specific name patterns — runs first. Co-Authored-By: Claude Opus 4.6 --- src/app/api/models/[modelId]/route.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/api/models/[modelId]/route.ts b/src/app/api/models/[modelId]/route.ts index 955e97a8..ec28e6b8 100644 --- a/src/app/api/models/[modelId]/route.ts +++ b/src/app/api/models/[modelId]/route.ts @@ -571,13 +571,15 @@ function extractParametersFromSchema( const inputs: ModelInput[] = []; for (const [name, prop] of Object.entries(properties)) { - // Check if this is a connectable input (image or text) - // Pass both name AND prop to check schema type, not just name - if (isImageInput(name, prop, schemaComponents)) { + // Check if this is a connectable input (audio, image, or text) + // Audio is checked first — it matches specific name patterns while image + // detection is more permissive (e.g. description heuristics like "data uri" + // can false-positive on audio properties). + if (isAudioInput(name, prop, schemaComponents)) { const resolvedType = resolvePropertyType(prop, schemaComponents).type; inputs.push({ name, - type: "image", + type: "audio", required: required.includes(name), label: toLabel(name), description: prop.description as string | undefined, @@ -586,11 +588,11 @@ function extractParametersFromSchema( continue; } - if (isAudioInput(name, prop, schemaComponents)) { + if (isImageInput(name, prop, schemaComponents)) { const resolvedType = resolvePropertyType(prop, schemaComponents).type; inputs.push({ name, - type: "audio", + type: "image", required: required.includes(name), label: toLabel(name), description: prop.description as string | undefined,