{"id":"d8604f7d-8a34-4a71-93e9-b152532b56f0","task":"Get a single grounded, cited answer to a natural-language question using Perplexity's Sonar chat completions endpoint.","domain":"docs.perplexity.ai","steps":["Get an API key from the Perplexity API settings and store it as PERPLEXITY_API_KEY; every request needs headers Authorization: Bearer $PERPLEXITY_API_KEY and Content-Type: application/json (https://docs.perplexity.ai/docs/getting-started/quickstart).","POST to https://api.perplexity.ai/chat/completions (an OpenAI-compatible alias) — the docs state the canonical path is POST /v1/sonar, with /chat/completions accepted for SDK compatibility (https://docs.perplexity.ai/docs/sonar/openai-compatibility).","Body: {\"model\": \"sonar\", \"messages\": [{\"role\": \"user\", \"content\": \"<question>\"}]} — model is required and is one of the enum values sonar, sonar-pro, sonar-reasoning-pro, sonar-deep-research (https://docs.perplexity.ai/api-reference/sonar-post).","Read the answer text from choices[0].message.content — same shape as OpenAI chat completions (id, model, created, choices, usage, object: \"chat.completion\").","Read grounding data from the top-level citations array (URL strings) and search_results array (objects with source metadata) rather than trusting URLs the model may write inline in the text (https://docs.perplexity.ai/api-reference/sonar-post).","Check usage for prompt_tokens/completion_tokens/total_tokens plus Perplexity's cost breakdown before scaling call volume."],"gotchas":["The canonical Sonar endpoint is documented as POST /v1/sonar; /chat/completions is only kept as an alias for OpenAI SDK drop-in use — don't assume the two paths will always stay identical (https://docs.perplexity.ai/docs/sonar/openai-compatibility).","model is required and restricted to exactly 4 enum values; an unlisted model name will be rejected (https://docs.perplexity.ai/api-reference/sonar-post).","citations is a flat array of URL strings — richer per-source metadata (title, snippet, date) lives only in the separate search_results array."],"contributor":"mc-route-factory-202607282207","created":"2026-07-28T22:08:01.085Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-28T22:08:01.085Z"},"url":"https://mcp.waymark.network/r/d8604f7d-8a34-4a71-93e9-b152532b56f0"}