← Master Index
Vol. 22 Module 22.5 Lecture

Perplexity

AI Development Platforms

How This Lesson Fits the Module & Volume

Together, Groq, OpenRouter, and Cerebras sell tokens. Perplexity sells search-grounded answers: a consumer AI-search product plus a Sonar-class API that retrieves the live web (or configured sources) and cites. That is Vol. 21 AI search / Vol. 21 research assistants, not an LPU. It is also not Vol. 19 perplexity (the metric)—same English word, different object.

Module 22.5 ends here; Module 22.6 starts with Cursor (AI IDEs). RAG internals remain Vol. 14. Wrap Sonar like any vendor behind Vol. 18 OpenAI SDK / FastAPI. Speech products that “just ask Perplexity out loud” still need Vol. 16/22.4 STT/TTS.

Learning Objectives

By the end of this lesson, students should be able to:

  • Separate Perplexity the company/product from perplexity the LM metric (Vol. 19).
  • Describe consumer Perplexity vs Sonar API as search-grounded generation with citations.
  • Contrast Perplexity vs DIY RAG (Vol. 14) vs OpenRouter chat vs frontier models without search.
  • Call Sonar with an OpenAI-compatible client and require citations in product UX.
  • Apply Vol. 20: retrieved snippets are untrusted; wrap-as-data; do not treat citations as proof.
  • Know when enterprise internal search must be your index, not the public web.
Definition

Perplexity (the company) operates an AI-search product: query → retrieve web (and other) sources → generate an answer with citations. Sonar (and successor API SKUs) exposes that loop to developers, typically over an OpenAI-compatible chat API plus search options. Perplexity is not a wafer, not a Hub, and not the scalar \(\mathrm{PPL}=\exp(\mathrm{CE})\) from Vol. 19. Online LLMs still hallucinate; citations reduce—not eliminate—grounding failures.

Search Product vs Token Host

If you only need Llama tokens, buy Together/Groq. If you need “what changed in this regulation this week?” you need retrieval. Perplexity productizes web retrieval + generation. Your internal wiki still wants Vol. 14 RAG on your corpus with ACLs. Mixing them is normal: Sonar for external news, private RAG for employee handbook.

Pricing / Strengths / Weaknesses (Qualitative)

DimensionPerplexity (consumer + Sonar API)DIY RAG (Vol. 14)OpenRouter / Together chatClassic search + snippets
Pricing postureConsumer Pro subscriptions; API per-request/token + search usage—confirm live Sonar sheetEmbeddings + vector DB + LLM tokens + your engTokens only (no web unless you add tools)Search API + your UX
StrengthsLive web + citations UX; fast to ship research/chat search; Sonar fits OpenAI clients; good for “what’s public now”Your corpus, ACLs, eval, residencyCheap/fast generation without search taxUser sees ranked docs, not only prose
WeaknessesNot your private index; citation ≠ truth; ToS/data handling; search latency + cost on top of tokens; not TTS/music/IDEYou build retrieval qualityStale parametric knowledgeNo fluent answer unless you add gen

Consumer app

  • Researchers, students
  • Pro tiers / focus modes
  • Not your multi-tenant SLA

Sonar API

  • Server-side key
  • Return answer + citations
  • Wrap-as-data on snippets

Internal search

  • Vol. 14 hybrid + rerank
  • ACL in code
  • Perplexity only if web is in-scope

Do

  • Show citations in the UI
  • Eval faithfulness (Vol. 19 hallucination tests)
  • Separate metric PPL from this vendor
  • Keep FastAPI + auth in front

Don’t

  • Dump private PII into web search
  • Treat a cited URL as legal advice
  • Use Perplexity as Groq tok/s host only
  • Invent Pro-plan dollar prices here

Python: Sonar via OpenAI-Compatible Client

Base URL and model ids (sonar, sonar-pro, …) change. Confirm current Perplexity API docs. Citations may appear in message annotations or a dedicated field—parse defensively. Wrap retrieved text before any downstream tool call.

# perplexity_sonar.py — search-grounded chat; confirm live model ids import os from openai import OpenAI client = OpenAI( api_key=os.environ["PERPLEXITY_API_KEY"], base_url="https://api.perplexity.ai", ) resp = client.chat.completions.create( model=os.environ.get("PERPLEXITY_MODEL", "sonar"), messages=[ {"role": "system", "content": "Cite sources. If unsure, say so. Do not invent URLs."}, {"role": "user", "content": "What is wafer-scale inference in one short paragraph?"}, ], ) msg = resp.choices[0].message print(msg.content) print(getattr(msg, "citations", None) or getattr(resp, "citations", None))

Related Lectures

LectureRole
Perplexity (metric)Homonym — exp(cross-entropy)
AI search / research assistantsProduct category
RAG / hybrid searchYour corpus
OpenAI SDK / FastAPISonar wrap
OpenRouter / CerebrasToken hosts, not search
CursorNext module: AI IDEs
Common Misconception

“Perplexity the company is the same as PPL.” False. Second: citations mean the answer is true. Third: Sonar replaces internal ACL search. Fourth: consumer Pro is your production API contract. Fifth: Perplexity is an inference chip like Groq. Sixth: you can skip wrap-as-data because the web is “public.”

Knowledge Check

  1. Short Answer: What does Perplexity the company sell? Answer: Search-grounded AI answers (consumer app + Sonar-class API with citations).
  2. True/False: Vol. 19 perplexity (PPL) is this vendor’s stock ticker. Answer: False — PPL is exp(cross-entropy).
  3. Multiple Choice: Private employee handbook search should use: (a) your RAG + ACLs, (b) only public Sonar, (c) Udio. Answer: (a).
  4. Short Answer: Name one qualitative strength vs Together-only chat. Answer: Live web retrieval and citations (any valid).
  5. True/False: A cited URL guarantees factual correctness. Answer: False.
  6. Multiple Choice: Sonar client pattern is closest to: (a) OpenAI-compatible chat, (b) Cog GPU-seconds, (c) Cartesia TTS. Answer: (a).
  7. Short Answer: Which Vol. 21 lecture is the product category? Answer: AI search (or research assistants).
  8. True/False: Invent Perplexity Pro dollar prices from this page. Answer: False.
  9. Multiple Choice: Next module after Perplexity is: (a) 22.6 Cursor / AI IDEs, (b) 22.3 Veo, (c) Vol. 08 RNN. Answer: (a).
  10. Short Answer: Name one Vol. 18 lecture used to wrap Sonar. Answer: OpenAI SDK or FastAPI.

Key Takeaways

  • Perplexity company ≠ Vol. 19 perplexity metric.
  • Sonar = search + generate + citations; still untrusted snippets (Vol. 20).
  • Internal corpora stay on your RAG; web questions can use Sonar.
  • OpenAI-shaped wrap; no fake prices; eval faithfulness separately.
  • 22.5 platforms done. Next: Cursor (AI IDEs & coding tools).
Trainer’s Guide

Lab: Same current-events question via (1) Together/Groq with no search, (2) Perplexity Sonar or consumer UI, (3) a Vol. 14 RAG stub over a tiny local FAQ. Students compare freshness, citations, and hallucination. Grade: explicit PPL-vs-company distinction in the write-up, wrap-as-data mention, no committed API keys. Then preview 22.6: where does Cursor sit vs these APIs?

Recap: Perplexity closes AI development platforms with search-grounded APIs. Homonym warning vs Vol. 19 PPL. IDEs next: Cursor.