Skip to content
Browse documentation
typescript sdk

Generate text and structured output

Request ordinary text or a schema-validated terminal object without trusting unparsed model output.

Generate a direct response

Use the server-owned inference instance from Models. Select a model explicitly; the model ID here is an example, not an availability guarantee.

const response = await inference.generate({
  model: "openai/gpt-5.4-mini",
  messages: [{ role: "user", content: "Summarize this request." }],
});
console.log(response.content);

Validate structured output

import { z } from "zod";

const response = await inference.generate({
  model: "openai/gpt-5.4-mini",
  messages: [{ role: "user", content: "Return the account status." }],
  output: {
    name: "account_status",
    schema: z.strictObject({ status: z.string() }),
    strict: true,
  },
});
console.log(response.output.status);

Smoothie validates the terminal response against the supported schema and exposes inferred output types. Invalid output is an error, not an object with an assumed type. Structured streaming validates the terminal result; partial objects are not a separate validated-output API.

With Tools enabled, a direct invocation can instead return an authorized Tool-call branch without output. Narrow that branch before using a structured result.

This is model output validation, not Whisk lowering. Use Whisk genUI for bounded UI documents.