// (e) Structured output via text.format json_schema strict. import { client, attempt, save, PROBE_MODELS, summarizeResponse } from "./lib"; const format: any = { type: "json_schema", name: "person", strict: true, schema: { type: "object", properties: { name: { type: "string" }, age: { type: "integer" }, city: { type: ["string", "null"] } }, required: ["name", "age", "city"], additionalProperties: false } }; const out: any[] = []; for (const model of PROBE_MODELS) { out.push(await attempt(`structured:${model}`, async () => { const r: any = await client.responses.create({ model, input: "Marie Curie, 66, lived in Paris. Extract.", text: { format }, max_output_tokens: 200 } as any); let parsed: any = null; try { parsed = JSON.parse(r.output_text); } catch { } return { ...summarizeResponse(r), parsed, text_format_echo: r.text }; })); } save("06-structured", out);