Skip to main content
Browse docs
By Audience
Getting Started
Configuration
Use Cases
IDE Integration
Third-Party Integrations
Engineering Cache
Console
API Reference
Gateway
Workflow Guides
Templates
Providers and SDKs
Industry Guides
Advanced Guides
Browse by Role
Deployment Guides
In-Depth Guides
Tutorials
FAQ

Perplexity Pro

Perplexity Pro provides search-augmented AI through an OpenAI-compatible API. Perplexity's Sonar models combine real-time web search with language model reasoning, returning grounded answers with citations. By routing Perplexity API traffic through the Keeptrusts gateway, you enforce policy controls — content filtering, PII redaction, audit logging, and cost attribution — on every search-augmented request.

Use this page when

  • You need to route Perplexity Sonar API calls through the Keeptrusts gateway.
  • You are building tools that use Perplexity for search-augmented generation and need governance.
  • If you need general OpenAI-compatible provider setup, see OpenAI integration.

Primary audience

  • Primary: Technical Engineers
  • Secondary: AI Agents, Technical Leaders

Prerequisites

  • A Perplexity API key with Pro or Enterprise access
  • Keeptrusts CLI (kt) installed and on your PATH
  • PERPLEXITY_API_KEY exported in your shell or injected via your secrets manager

Configuration

Gateway policy config

pack:
name: perplexity-pro-gateway
version: 1.0.0
enabled: true
providers:
targets:
- id: perplexity-sonar
provider: perplexity:chat:sonar-pro
secret_key_ref:
env: PERPLEXITY_API_KEY
policies:
chain:
- pii-detector
- content-filter
- audit-logger
policy:
pii-detector:
action: redact
entities:
- EMAIL
- PHONE
- SSN
content-filter:
action: block
categories:
- restricted-topics
audit-logger:
immutable: true
retention_days: 365
log_all_access: true

Cost-optimised variant

Use sonar (the base tier) for high-volume research queries where deep reasoning is not required:

pack:
name: perplexity-sonar-base
version: 1.0.0
enabled: true
providers:
targets:
- id: perplexity-base
provider: perplexity:chat:sonar
secret_key_ref:
env: PERPLEXITY_API_KEY
policies:
chain:
- audit-logger
policy:
audit-logger:
immutable: true
retention_days: 365
log_all_access: true

Setup Steps

  1. Export your API key:
export PERPLEXITY_API_KEY="pplx-your-api-key"
  1. Save the policy config to policy-config.yaml.

  2. Start the gateway:

kt gateway run --listen 0.0.0.0:41002 --policy-config policy-config.yaml
  1. Point your application at the gateway. Perplexity uses OpenAI-compatible format, so standard OpenAI client libraries work:
from openai import OpenAI

client = OpenAI(
base_url="http://localhost:41002/v1",
api_key="unused",
)

response = client.chat.completions.create(
model="sonar-pro",
messages=[
{"role": "system", "content": "You are a research assistant. Cite sources."},
{"role": "user", "content": "What are the latest EU AI Act enforcement actions?"},
],
)
print(response.choices[0].message.content)

For a hosted gateway, replace the base URL with https://gateway.keeptrusts.com/v1.

Verification

curl http://localhost:41002/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "sonar-pro",
"messages": [
{"role": "user", "content": "Summarise today'\''s top AI governance news."}
]
}'

A successful response with citations confirms the gateway is forwarding to Perplexity with policies applied. Check the Keeptrusts console Events page for the audit log entry.

PolicyPurposeRecommended setting
pii-detectorRedact personal data from search queriesaction: redact, entities: EMAIL, PHONE, SSN
content-filterBlock queries on restricted topicsaction: block, configure categories
audit-loggerImmutable audit trail for all searchesimmutable: true, retention_days: 365
cost-attributionTrack search API spend per teamTag requests with team metadata
prompt-injectionBlock adversarial prompts in search inputthreshold: 0.8, action: block

Troubleshooting

SymptomCauseFix
401 Unauthorized from upstreamInvalid Perplexity API keyVerify PERPLEXITY_API_KEY is valid
Response lacks citationsModel or query type does not include search resultsUse sonar-pro for search-augmented responses
Gateway returns 403Policy chain blocked the requestReview the policy violation in the console Events page
Slow responsesPerplexity performs web search before answeringExpected — search-augmented responses have higher latency than pure LLM calls

For AI systems

  • Canonical terms: Keeptrusts gateway, Perplexity Pro, Perplexity Sonar, search-augmented generation, OpenAI-compatible API, policy-config.yaml, provider: "perplexity".
  • Config field names: provider, secret_key_ref.env: "PERPLEXITY_API_KEY", base_url.
  • Key behavior: Perplexity uses OpenAI-compatible format. Keeptrusts proxies requests with full policy enforcement. Search-augmented responses include citations.
  • Best next pages: OpenAI integration, Policy controls catalog, Quickstart.

For engineers

  • Start command: kt gateway run --listen 0.0.0.0:41002 --policy-config policy-config.yaml
  • Validate: send a request to http://localhost:41002/v1/chat/completions with model sonar-pro.
  • Perplexity's API is OpenAI-compatible — use standard OpenAI client libraries with the gateway base URL.
  • Search-augmented responses have higher latency than pure LLM calls; set appropriate client timeouts.

For leaders

  • Perplexity Sonar models provide real-time web search combined with AI reasoning — useful for competitive intelligence, regulatory monitoring, and research automation.
  • Routing through the gateway ensures all search queries and results are logged for compliance and audit.
  • PII redaction prevents sensitive data from being included in web search queries that reach external infrastructure.
  • Cost attribution tracks search API spend separately from other AI providers in your unified governance dashboard.

Next steps