Skip to main content
Perplexity offers 4 models through Lava’s AI Gateway, supporting Chat Completions. Authentication uses Authorization: Bearer. See the Perplexity API docs for provider-specific parameters.
Supports both managed API keys (from Lava) and BYOK mode.

Quick Start

const response = await fetch('https://api.lavapayments.com/v1/forward?u=https%3A%2F%2Fapi.perplexity.ai%2Fchat%2Fcompletions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${forwardToken}`,
  },
  body: JSON.stringify({
    model: 'sonar-deep-research',
    messages: [{ role: "user", content: "Hello!" }],
  }),
});

Chat Completions

Target URL: https://api.perplexity.ai/chat/completions
Content Typeapplication/json
StreamingYes (set stream: true in request body)
ModelInput / 1M tokensOutput / 1M tokens
sonar-pro$3.00$15.00
sonar-deep-research$2.00$8.00
sonar-reasoning-pro$2.00$8.00
sonar$1.00$1.00

Next Steps