v0.6.0 — JSON Schema structured output
SDK — JSON Schema structured output
The CloudTrain SDK now supports OpenAI-compatible structured output via response_format, with three usage modes:
chat<T>() — non-streaming, auto-parsed
```ts
const completion = await client.chat({
messages,
response_format: { type: "json_schema", json_schema: { name, schema, strict: true } },
});
const email = completion.choices[0].message.content; // typed MarketingEmail
```
chatStream<T>() — streamed, parsed on complete
Chunks fire as raw strings during the stream (for progress UX); onComplete receives the fully-parsed T.
chatStreamPartial<T>() — progressive JSON streaming (CloudTrain extension)
SDK parses the partial-json SSE stream and emits a Partial<T> per event for generative-UI patterns (live form fills, progressive lists, comparison cards).
Types
Message<T = string>andChatCompletion<T = string>are now generic- New
ResponseFormattype exported - All existing call sites are backward compatible (defaults preserve current behavior)
Other
- 9 new tests covering request serialization, auto-parse, backward compat, buffered + partial streaming, and SSE chunk-boundary handling