@mozaik-ai/core 3.11.0 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -218,6 +218,53 @@ Enable streaming on the model before calling `runInference` as usual. `setStream
218
218
 
219
219
  ---
220
220
 
221
+ ## Structured output
222
+
223
+ When you need the model to respond with a specific JSON shape instead of free-form text, use structured output. Set a JSON Schema on the model and the provider will enforce it:
224
+
225
+ ```ts
226
+ import { Gpt54, ModelContext, UserMessageItem } from "@mozaik-ai/core"
227
+
228
+ const model = new Gpt54()
229
+ model.setStructuredOutput({
230
+ name: "weather",
231
+ schema: {
232
+ type: "object",
233
+ properties: {
234
+ city: { type: "string" },
235
+ temperature: { type: "number" },
236
+ condition: { type: "string" },
237
+ },
238
+ required: ["city", "temperature", "condition"],
239
+ additionalProperties: false,
240
+ },
241
+ strict: true,
242
+ })
243
+ ```
244
+
245
+ The response comes back as a `ModelMessageItem` with valid JSON in the text field — no new item type, consistent with OpenResponses.
246
+
247
+ Structured output works alongside tools and streaming. When streaming is enabled, partial JSON chunks arrive as `SemanticEvent`s and the final event contains the complete response.
248
+
249
+ To clear structured output and return to free-form text:
250
+
251
+ ```ts
252
+ model.setStructuredOutput(undefined)
253
+ ```
254
+
255
+ ### Provider support
256
+
257
+ | Provider | Models | Strict schema enforcement |
258
+ | -------- | ------ | ------------------------- |
259
+ | OpenAI | gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.5 | Yes |
260
+ | Anthropic | claude-opus-4-7, claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 | Yes |
261
+ | Gemini | gemini-3.1-pro, gemini-3.5-flash | Yes |
262
+ | DeepSeek | deepseek-v4-flash, deepseek-v4-pro | Not supported — use prompt-based JSON guidance instead |
263
+
264
+ Setting structured output on a model that does not support it throws before the API call.
265
+
266
+ ---
267
+
221
268
  ## Lifecycle hooks
222
269
 
223
270
  Every participant receives lifecycle notifications when it or others join/leave an environment: