diff --git a/lib/ai/providers/alibaba-image.ts b/lib/ai/providers/alibaba-image.ts index 4b2c6e9..24ecf2d 100644 --- a/lib/ai/providers/alibaba-image.ts +++ b/lib/ai/providers/alibaba-image.ts @@ -333,14 +333,17 @@ export function createAlibabaImage({ apiKey, baseURL }: AlibabaImageConfig) { } else { imageUrls.push(imageUrl); } - } else if (part.type === "file" && (part as any).url) { - // 格式3: { type: "file", url: string } - 来自 ChatMessage 的原始格式 - const fileUrl = (part as any).url; - if (fileUrl.startsWith("data:")) { - const url = await uploadBase64ToS3(fileUrl); - imageUrls.push(url); - } else { - imageUrls.push(fileUrl); + } else if (part.type === "file") { + // 格式3: { type: "file", url/data: string } - 来自 ChatMessage 的原始格式 + // AI SDK convertToModelMessages 会将 url 转换为 data 字段 + const fileUrl = (part as any).url || (part as any).data; + if (fileUrl) { + if (fileUrl.startsWith("data:")) { + const url = await uploadBase64ToS3(fileUrl); + imageUrls.push(url); + } else { + imageUrls.push(fileUrl); + } } } }