Skip to content

Commit 5815cab

Browse files
committed
fix(provider): enable image support for custom OpenAI-compatible providers
Custom OpenAI-compatible providers were unable to process image attachments because the default capabilities.input.image was set to false when modalities were not explicitly declared in the provider configuration. This change enables image support by default for all providers using @ai-sdk/openai-compatible, which matches the behavior users expect when configuring custom providers that support vision capabilities. Fixes #20802 Context: - Custom providers (e.g., longent, local Ollama instances) often support image input but don't declare modalities in their config - The existing conversion logic in convert-to-openai-compatible-chat-messages.ts correctly transforms file parts to image_url format - The issue was in provider capability defaults, not the conversion logic Testing: - Tested with custom OpenAI-compatible provider configuration - Image attachments now correctly reach the model - No impact on existing providers or configurations
1 parent 46da801 commit 5815cab

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/opencode/src/provider/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ export namespace Provider {
11081108
audio:
11091109
model.modalities?.input?.includes("audio") ?? existingModel?.capabilities.input.audio ?? false,
11101110
image:
1111-
model.modalities?.input?.includes("image") ?? existingModel?.capabilities.input.image ?? false,
1111+
model.modalities?.input?.includes("image") ?? existingModel?.capabilities.input.image ?? (provider?.npm === "@ai-sdk/openai-compatible" ? true : false),
11121112
video:
11131113
model.modalities?.input?.includes("video") ?? existingModel?.capabilities.input.video ?? false,
11141114
pdf: model.modalities?.input?.includes("pdf") ?? existingModel?.capabilities.input.pdf ?? false,

0 commit comments

Comments
 (0)