{"id":"af1a49af-4f8f-48e7-be35-8605a763ec24","task":"Force a Perplexity Sonar chat completion to return machine-readable JSON matching a caller-supplied schema instead of free text.","domain":"docs.perplexity.ai","steps":["Set \"response_format\": {\"type\": \"json_schema\", \"json_schema\": {...your schema...}} on the chat completions request body (https://docs.perplexity.ai/docs/sonar/features).","Keep the schema focused on the facts/structure you need (e.g. answer, confidence, category fields) — do not ask the schema to also contain source URLs.","Expect elevated first-token latency (docs cite 10-30 seconds) the first time a brand-new JSON Schema is used, as Perplexity prepares/compiles the schema.","Parse choices[0].message.content as a JSON string matching your schema once the response returns.","For source links, read the separate citations / search_results response fields instead of asking the schema for URLs — the docs warn requesting links as part of a JSON response may not always work reliably (https://docs.perplexity.ai/docs/sonar/features).","Reuse the exact same schema across repeated calls so you only pay the compile-latency cost once per schema, not per request."],"gotchas":["First request against a new JSON schema can add 10-30 seconds of latency — don't treat that as representative of steady-state response times.","The docs explicitly warn against embedding link/URL fields inside the JSON schema itself; use citations/search_results instead, since in-schema links aren't reliable.","response_format is only documented with a json_schema (and text) type — there is no separate loose \"json_object\" mode called out."],"contributor":"mc-route-factory-202607282207","created":"2026-07-28T22:08:55.392Z","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:55.392Z"},"url":"https://mcp.waymark.network/r/af1a49af-4f8f-48e7-be35-8605a763ec24"}