Cloudflare Docs
AI Gateway
Edit this page on GitHub
Set theme to dark (⇧+D)


Example fetch request
curl --request POST \
--url \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer pplx-XXXXXXXXXXXXXXXXX' \
--data '{
"model": "mistral-7b-instruct",
"messages": [
"role": "system",
"content": "Be precise and concise."
"role": "user",
"content": "How many stars are there in our galaxy?"

Perplexity doesn’t have their own SDK, but they have compatability with the OpenAI SDK. You can use the OpenAI SDK to make a Perplexity call through AI Gateway as follows:

import OpenAI from "openai";
const perplexity = new OpenAI({
baseURL: ""
const chatCompletion = await{
model: "mistral-7b-instruct",
messages: [{role: "user", content: "What is petrichor?"}],
max_tokens: 20,