Perplexity transport — OpenAI-shape body + citation/search-results surfacing.
Request building is identical to openai-chat. Response parsing extends the OpenAI parser with two extractions:
Usage normalization delegates to normalize-openai-usage, which already picks up Perplexity's :citation_tokens and :num_search_queries when present.
Streaming: the final SSE chunk on /chat/completions carries :citations alongside :usage and :finish_reason. parse-stream-event returns a vector of events in that case — sdk/complete flattens multi-event return values.
Perplexity transport — OpenAI-shape body + citation/search-results
surfacing.
Request building is identical to openai-chat. Response parsing
extends the OpenAI parser with two extractions:
- :search_results [{:url :title :snippet}, ...] → richer
CitationPart per result
- :citations ["url", ...] → URL-only
CitationPart when search_results isn't present
Usage normalization delegates to normalize-openai-usage, which
already picks up Perplexity's :citation_tokens and
:num_search_queries when present.
Streaming: the final SSE chunk on /chat/completions carries
:citations alongside :usage and :finish_reason. parse-stream-event
returns a vector of events in that case — sdk/complete flattens
multi-event return values.(extract-citation-parts raw)Return a vector of CitationPart maps from a Perplexity raw response. Prefers :search_results (carries title + snippet); falls back to :citations (URL-only).
Return a vector of CitationPart maps from a Perplexity raw response. Prefers :search_results (carries title + snippet); falls back to :citations (URL-only).
(parse-stream-event-perplexity _profile line)Parse a Perplexity SSE line into one or more StreamEvents.
Perplexity streams the same shape as OpenAI for content deltas. The final chunk packs citations, usage, and finish_reason together, so this returns a vector of events for that line (and a single event for the rest).
Parse a Perplexity SSE line into one or more StreamEvents. Perplexity streams the same shape as OpenAI for content deltas. The final chunk packs citations, usage, and finish_reason together, so this returns a vector of events for that line (and a single event for the rest).
(perplexity-cost-calculator {:keys [_provider _model usage pricing]})Reads canonical token + search-query usage and produces a cost-result. Falls back to the default token cost when no :search-cost-per-call is set.
Reads canonical token + search-query usage and produces a cost-result. Falls back to the default token cost when no :search-cost-per-call is set.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |