Skip to content

v0.6.0 — JSON Schema structured output

Choose a tag to compare

@ramonmalcolm10 ramonmalcolm10 released this 17 May 18:21
· 20 commits to main since this release

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> and ChatCompletion<T = string> are now generic
  • New ResponseFormat type 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