@@ -47,6 +47,8 @@ export function isContentMedia(part: unknown): part is ContentMedia {
4747 hasInputAudio ( part ) ||
4848 hasFileData ( part ) ||
4949 hasMediaTypeData ( part ) ||
50+ hasVercelFileData ( part ) ||
51+ hasVercelImageData ( part ) ||
5052 hasBlobOrBase64Type ( part ) ||
5153 hasB64Json ( part ) ||
5254 hasImageGenerationResult ( part ) ||
@@ -113,6 +115,34 @@ function hasMediaTypeData(part: NonNullable<unknown>): part is { media_type: str
113115 return 'media_type' in part && typeof part . media_type === 'string' && 'data' in part ;
114116}
115117
118+ /**
119+ * Check for Vercel AI SDK file format: { type: "file", mediaType: "...", data: "..." }
120+ */
121+ function hasVercelFileData ( part : NonNullable < unknown > ) : part is { type : 'file' ; mediaType : string ; data : string } {
122+ return (
123+ 'type' in part &&
124+ part . type === 'file' &&
125+ 'mediaType' in part &&
126+ typeof part . mediaType === 'string' &&
127+ 'data' in part &&
128+ typeof part . data === 'string'
129+ ) ;
130+ }
131+
132+ /**
133+ * Check for Vercel AI SDK image format: { type: "image", image: "base64...", mimeType: "..." }
134+ */
135+ function hasVercelImageData ( part : NonNullable < unknown > ) : part is { type : 'image' ; image : string ; mimeType : string } {
136+ return (
137+ 'type' in part &&
138+ part . type === 'image' &&
139+ 'image' in part &&
140+ typeof part . image === 'string' &&
141+ 'mimeType' in part &&
142+ typeof part . mimeType === 'string'
143+ ) ;
144+ }
145+
116146function hasBlobOrBase64Type ( part : NonNullable < unknown > ) : part is { type : 'blob' | 'base64' ; content : string } {
117147 return 'type' in part && ( part . type === 'blob' || part . type === 'base64' ) ;
118148}
@@ -131,7 +161,7 @@ function hasDataUri(part: NonNullable<unknown>): part is { uri: string } {
131161
132162const REMOVED_STRING = '[Blob substitute]' ;
133163
134- const MEDIA_FIELDS = [ 'image_url' , 'data' , 'content' , 'b64_json' , 'result' , 'uri' ] as const ;
164+ const MEDIA_FIELDS = [ 'image_url' , 'data' , 'content' , 'b64_json' , 'result' , 'uri' , 'image' ] as const ;
135165
136166/**
137167 * Replace inline binary data in a single media content part with a placeholder.
0 commit comments