Use Perplexity for SQL Apps

Hi,

I am doing a course on Deeplearning.ai: Building Your Own Database Agent - DeepLearning.AI

My goal is to make an SQL app using the perplexity app. However, when converting the code that is provided in the course material I am getting stuck completely. The course is using OPENAI API.

Do you know about an example of a database app that I can use so that I can practice and learn SQL apps using Perpelxiity API?

Thanks,

Naveen

1 Like

Most companies’ endpoint calling methods are compatible with the OpenAI API. For Perplexity, it seems possible to call it from the openai library as well.

# pip install openai
from openai import OpenAI
client = OpenAI(base_url="https://api.perplexity.ai", api_key="PPLX_API_KEY")

resp = client.chat.completions.create(
    model="sonar-reasoning-pro",  # good for multi-step SQL generation
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)