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/providers/01-ai-sdk-providers/70-perplexity.mdx
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,48 @@ The metadata includes:
133
133
134
134
You can enable image responses by setting `return_images: true` in the provider options. This feature is only available to Perplexity Tier-2 users and above.
135
135
136
+
### PDF Support
137
+
138
+
The Perplexity provider supports reading PDF files.
139
+
You can pass PDF files as part of the message content using the `file` type:
140
+
141
+
```ts
142
+
const result =awaitgenerateText({
143
+
model: perplexity('sonar-pro'),
144
+
messages: [
145
+
{
146
+
role: 'user',
147
+
content: [
148
+
{
149
+
type: 'text',
150
+
text: 'What is this document about?',
151
+
},
152
+
{
153
+
type: 'file',
154
+
data: fs.readFileSync('./data/ai.pdf'),
155
+
mediaType: 'application/pdf',
156
+
filename: 'ai.pdf', // optional
157
+
},
158
+
],
159
+
},
160
+
],
161
+
});
162
+
```
163
+
164
+
You can also pass the URL of a PDF:
165
+
166
+
```ts
167
+
{
168
+
type: 'file',
169
+
data: newURL('https://example.com/document.pdf'),
170
+
mediaType: 'application/pdf',
171
+
filename: 'document.pdf', // optional
172
+
}
173
+
```
174
+
175
+
The model will have access to the contents of the PDF file and
176
+
respond to questions about it.
177
+
136
178
<Note>
137
179
For more details about Perplexity's capabilities, see the [Perplexity chat
0 commit comments