You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/servers/structured-output.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,10 @@ No `output_schema`, no wrapping, no validation. `structured_content` is `None` a
208
208
209
209
The opposite, `structured_output=True`, turns the automatic detection into a requirement: a tool whose return type can't produce a schema raises at import time instead of falling back to text.
210
210
211
+
## Content blocks and media
212
+
213
+
Content blocks and media (`TextContent`, `EmbeddedResource`, `Image`, `Audio` and friends, on their own, as the items of a `list`, `tuple` or `Sequence`, or as the arms of a union) are opted out for you: they are for the model to read, so auto-detection derives no schema from them (**[Images, audio & icons](media.md)** covers `Image` and `Audio`). `structured_output=True` still forces one for the content-block classes.
214
+
211
215
## A class without type hints
212
216
213
217
There is one way to end up unstructured without asking for it: return a class that has **no annotations on its body**.
@@ -240,6 +244,6 @@ There is one way to end up unstructured without asking for it: return a class th
240
244
* Scalars, lists, tuples and unions are wrapped in `{"result": ...}`. Models, `TypedDict`s, dataclasses, annotated classes and `dict[str, ...]` are objects already and stay as they are.
241
245
* Every result carries `content` (text, for the model) **and**`structured_content` (data, for the application).
242
246
* What you return is validated against the schema. A mismatch is a tool error, not a corrupt result.
243
-
*`structured_output=False` opts a tool out. A class without type hints opts out silently; watch for it.
247
+
*`structured_output=False` opts a tool out. Content blocks, `Image` and `Audio` opt out by default; a class without type hints opts out silently, so watch for it.
244
248
245
249
You now own everything a tool can say back. Next, the second primitive: **[Resources](resources.md)**.
0 commit comments