Level Up Your B4X Projects with Perplexity AI Integration!

I'm excited to share my latest B4X Community contribution: A powerful example of how to connect with the Perplexity API from your B4X apps!
With this code, you will learn how to:

Instantly receive AI-powered responses to any text query.

Upload an image to Perplexity and get insightful answers based on that image.

Upload images to your own secure server (Apache + PHP), generate a link, and use it to get contextual answers from Perplexity. Learn a simple but robust method to handle file uploads while maintaining strong server security.
This example is more than just an API wrapper—it's a step-by-step guide:
- Build your own Perplexity Assistant in B4X (B4A, B4J, B4i)
- Effortlessly upload files to Perplexity for multimodal queries
- Safely handle uploads on your own web server with best practices for security
Some Important Info that will help you with the code
At the Main you can change API Key, and token for upload.php use from client... the same token must change in upload.php too...
You need API Key from Perplexity, so an account of Perplexity Pro (20$/month) - and you have some credit 5$ for api usage - but hey now - there is one month free trial:
https://perplexity.ai/pro?referral_code=L0QEHAAY
For upload.php need PHP, Apache Server... put it on a subdirectory, perhaps... into ai and inside of it create another one (with write permissions) with name uploads
Change the line 214 and 224-225 in project at perplexity.bas with your server urls..
Default TOKEN for upload.php: TEST123
The 2nd button of Form - can upload a jpeg file at perplexity server... but many times i got the following error (that's why i ve create upload.php for my vps):
Error: {"error":{"message":"An internal server error has occurred.","type":"internal_server_error","code":500}}
Enjoying my work?
Support my contributions and help me continue building for the B4X Community!

Let's make the B4X ecosystem smarter together!

Looking forward to your feedback, improvements, and questions!