Skip to content

Conversation

@goyalshivansh2805
Copy link
Contributor

@goyalshivansh2805 goyalshivansh2805 commented Nov 8, 2025

Background

The Perplexity provider currently doesn't support PDF upload functionality, although the direct Perplexity API supports this feature. Other providers in the AI SDK like OpenAI, Gemini, and Anthropic already have this capability, making the Perplexity implementation incomplete compared to these providers.

Summary

Added PDF support to the Perplexity provider, allowing users to:

  • Upload PDF files directly using base64 encoding
  • Reference PDF files via URLs
  • Include optional filename parameter

Implementation includes:

  • Updated message conversion logic to handle PDF files
  • Modified PerplexityMessageContent type to include file_url type
  • Added documentation for PDF support
  • Created example files demonstrating PDF usage

Manual Verification
I manually verified the changes by:

  • Creating a test file that uses the Perplexity provider with PDF files
  • Testing with both local PDF files and URL-based PDFs
  • Confirming that the provider correctly formats the requests according to Perplexity API requirements
  • Verifying that the API returns appropriate responses when analyzing PDF content

Both base64-encoded PDFs and URL-based PDFs work correctly, and the optional filename parameter is properly handled.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues
Fixes: #9803

@goyalshivansh2805 goyalshivansh2805 changed the title Feat/perplexity pdf support feat(provider/perplexity): Add PDF support Nov 8, 2025
@gr2m gr2m added feature New feature or request ai/provider backport provider/perplexity Issues related to the @ai-sdk/perplexity provider labels Nov 9, 2025
@dancer
Copy link
Collaborator

dancer commented Nov 10, 2025

Thank for the PR @goyalshivansh2805

Tested it out and works perfectly

@dancer dancer enabled auto-merge (squash) November 10, 2025 19:01
@dancer dancer self-requested a review November 10, 2025 19:02
@dancer dancer merged commit 4b06776 into vercel:main Nov 10, 2025
20 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Nov 10, 2025
**Background**

The Perplexity provider currently doesn't support PDF upload
functionality, although the direct Perplexity API supports this feature.
Other providers in the AI SDK like OpenAI, Gemini, and Anthropic already
have this capability, making the Perplexity implementation incomplete
compared to these providers.

**Summary**

Added PDF support to the Perplexity provider, allowing users to:
- Upload PDF files directly using base64 encoding
- Reference PDF files via URLs
- Include optional filename parameter

Implementation includes:
- Updated message conversion logic to handle PDF files
- Modified PerplexityMessageContent type to include file_url type
- Added documentation for PDF support
- Created example files demonstrating PDF usage

Checklist
- [x] Tests have been added / updated (for bug fixes / features)
- [x] Documentation has been added / updated (for bug fixes / features)
- [x] A patch changeset for relevant packages has been added (for bug
fixes / features - run pnpm changeset in the project root)
- [x] I have reviewed this pull request (self-review)

Related Issues
Fixes: #9803
@vercel-ai-sdk vercel-ai-sdk bot removed the backport label Nov 10, 2025
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Nov 10, 2025

✅ Backport PR created: #10130

dancer added a commit that referenced this pull request Nov 10, 2025
This is an automated backport of #10089 to the release-v5.0 branch. FYI
@goyalshivansh2805

---------

Co-authored-by: Shivansh Goyal <[email protected]>
Co-authored-by: josh <[email protected]>
Please see the [Perplexity docs](https://docs.perplexity.ai) for detailed API
documentation and the latest updates.
</Note>
```
Copy link
Collaborator

@nicoalbanese nicoalbanese Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @goyalshivansh2805 @dancer this broke our docs build. Just a note for future PRs to doublecheck that formatters don't add anything like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for pointing that out! I’ll make sure to double-check for any formatter artifacts before pushing future PRs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

nicoalbanese added a commit that referenced this pull request Nov 12, 2025
## Background

Docs builds are failing right now due to formatting issue introduced in
#10089.
vercel-ai-sdk bot pushed a commit that referenced this pull request Nov 12, 2025
## Background

Docs builds are failing right now due to formatting issue introduced in
#10089.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider feature New feature or request provider/perplexity Issues related to the @ai-sdk/perplexity provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF upload support in Perplexity

4 participants