Skip to content

Commit 0bd5bc6

Browse files
authoredMar 19, 2025··
feat (ai): support model-generated files (#5216)
1 parent 5cd3d6c commit 0bd5bc6

File tree

72 files changed

+2911
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2911
-287
lines changed
 

‎.changeset/thirty-grapes-decide.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@ai-sdk/provider': patch
3+
'@ai-sdk/google': patch
4+
'ai': patch
5+
---
6+
7+
feat (ai): support model-generated files

‎content/docs/02-foundations/03-prompts.mdx

+26
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,32 @@ const result = await generateText({
324324
});
325325
```
326326

327+
#### Example: Assistant message with file content
328+
329+
<Note>
330+
This content part is for model-generated files. Only a few models support
331+
this, and only for file types that they can generate.
332+
</Note>
333+
334+
```ts
335+
const result = await generateText({
336+
model: yourModel,
337+
messages: [
338+
{ role: 'user', content: 'Generate an image of a roquefort cheese!' },
339+
{
340+
role: 'assistant',
341+
content: [
342+
{
343+
type: 'file',
344+
mimeType: 'image/png',
345+
data: fs.readFileSync('./data/roquefort.jpg'),
346+
},
347+
],
348+
},
349+
],
350+
});
351+
```
352+
327353
### Tool messages
328354

329355
<Note>

0 commit comments

Comments
 (0)
Please sign in to comment.