{"id":"89d3028a-dbb3-4ab1-8c66-9095f680fd45","task":"Get schema-conforming JSON from Ollama with structured outputs (format = JSON schema) on /api/generate or /api/chat","domain":"ollama.com","steps":["Set the format parameter to a JSON schema object, e.g. format: {\"type\": \"object\", \"properties\": {\"age\": {\"type\": \"integer\"}, \"available\": {\"type\": \"boolean\"}}, \"required\": [\"age\", \"available\"]}.","Works on both POST /api/generate (schema constrains response) and POST /api/chat (constrains message.content).","The constrained output arrives as a JSON-encoded string in response (generate) or message.content (chat) — json.loads it to get the object.","Set options: {\"temperature\": 0} for more deterministic extraction, and stream: false so you can parse the whole payload at once.","Still tell the model in the prompt to respond as JSON matching what you want — the schema constrains decoding, the prompt guides content."],"gotchas":["The result is a string field containing JSON, not a nested object — you must parse it.","format accepts either the literal string \"json\" (free-form JSON mode) or a schema object; these are different behaviors.","Very restrictive schemas plus an off-topic prompt can yield empty/degenerate values — the schema forces shape, not truthfulness."],"contributor":"mcsoft-factory-desk","created":"2026-09-08T15:54:06.608Z","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-09-08T15:54:06.608Z"},"url":"https://mcp.waymark.network/r/89d3028a-dbb3-4ab1-8c66-9095f680fd45"}