You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: content/docs/03-ai-sdk-core/03-prompts.mdx
+19-10
Original file line number
Diff line number
Diff line change
@@ -76,15 +76,27 @@ const result = await generateText({
76
76
Instead of sending a text in the `content` property, you can send an array of parts that include text and other data types.
77
77
Currently image and text parts are supported.
78
78
79
-
For models that support multi-modal inputs, user messages can include images. An `image` can be a base64-encoded image (`string`), an `ArrayBuffer`, a `Uint8Array`,
80
-
a `Buffer`, or a `URL` object. It is possible to mix text and multiple images.
79
+
For models that support multi-modal inputs, user messages can include images. An `image` can be one of the following:
80
+
81
+
- base64-encoded image:
82
+
-`string` with base-64 encoded content
83
+
- data URL `string`, e.g. `data:image/png;base64,...`
84
+
- binary image:
85
+
-`ArrayBuffer`
86
+
-`Uint8Array`
87
+
-`Buffer`
88
+
- URL:
89
+
- http(s) URL `string`, e.g. `https://example.com/image.png`
90
+
-`URL` object, e.g. `new URL('https://example.com/image.png')`
91
+
92
+
It is possible to mix text and multiple images.
81
93
82
94
<Notetype="warning">
83
95
Not all models support all types of multi-modal inputs. Check the model's
84
96
capabilities before using this feature.
85
97
</Note>
86
98
87
-
#### Example: Buffer images
99
+
#### Example: Binary image (Buffer)
88
100
89
101
```ts highlight="8-11"
90
102
const result =awaitgenerateText({
@@ -104,9 +116,7 @@ const result = await generateText({
104
116
});
105
117
```
106
118
107
-
#### Example: Base-64 encoded images
108
-
109
-
<Note>You do not need a `data:...` prefix for the base64-encoded image.</Note>
119
+
#### Example: Base-64 encoded image (string)
110
120
111
121
```ts highlight="8-11"
112
122
const result =awaitgenerateText({
@@ -126,9 +136,9 @@ const result = await generateText({
126
136
});
127
137
```
128
138
129
-
#### Example: Image URLs
139
+
#### Example: Image URL (string)
130
140
131
-
```ts highlight="8-13"
141
+
```ts highlight="8-12"
132
142
const result =awaitgenerateText({
133
143
model: yourModel,
134
144
messages: [
@@ -138,9 +148,8 @@ const result = await generateText({
138
148
{ type: 'text', text: 'Describe the image in detail.' },
0 commit comments