askStructured
askStructured<
T>(schema,opts):Promise<AskStructuredResult<T>>
Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/runtime/askStructured.ts:181
Ask the configured model for a single schema-validated object — a non-agentic structured-output call that mirrors their mechanism (see the module doc) and never throws.
- No usable model (
config.llmmissing or lackingwithStructuredOutput) →{ ok: false, error: 'No usable model configured.' }. - Timeout →
ok: falsewith the error structuredCallTimedOutError builds for that budget. - Output that fails
schema.safeParse→{ ok: false, error: {@link STRUCTURED_CALL_UNPARSEABLE_ERROR} }. - Any thrown error →
{ ok: false, error: <message> }— a provider rejection (e.g. OpenAI’s 400 on a strictjson_schema), an auth or transport failure. Distinct from the two above BY CODE PATH, so a caller can classify a failure by comparing against those two exported texts. - Success →
{ ok: true, value }with the parsed data.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”schema
Section titled “schema”ZodType<T>
The Zod schema the model output must satisfy; <T> is inferred from it.
The model (via config.llm), the system/user message texts, and an optional timeout.
Returns
Section titled “Returns”Promise<AskStructuredResult<T>>