Overview
Perplexity's LLMs focus on providing helpful, up-to-date, and factual responses. Our first of a kind Online LLMs have access to information from the internet.
Instructions
To integrate pplx-api into your vercel project, follow the redirect to the Perplexity API settings portal. After you add your payment information and generate your first API key, a modal will ask you to creating the PERPLEXITY_API_KEY environment variable in selected Vercel projects. For more details, follow the steps in our getting started docs and API reference.
Instructions
After installing the integration, you can use the following code snippet to make a sample request to the pplx-7b-online
model.
const url = 'https://api.perplexity.ai/chat/completions';const headers = {'Accept': 'application/json','Content-Type': 'application/json','Authorization': `Bearer ${PERPLEXITY_API_KEY}` // Fetch from your project's environment variables};const body = {"model": "pplx-7b-online","stream": false,"max_tokens": 1024,"frequency_penalty": 1,"temperature": 0.0,"messages": [{"role": "system","content": "Be precise and concise in your responses."},{"role": "user","content": "How many stars are there in our galaxy?"}]};fetch(url, {method: 'POST',headers: headers,body: JSON.stringify(body)}).then(response => response.json()).then(data => console.log(data)).catch((error) => console.error('Error:', error));