Intelligence · function

requireStructuredOutput

Ask for output shaped like a schema, or refuse before spending anything.

Explained in Agents and behaviour.

function requireStructuredOutput(provider: AiProvider | null, schema: ToolSchema, value: unknown): StructuredResult
import { requireStructuredOutput } from '@driftengine/ai';

Parameters

ParameterTypeDescription
providerAiProvider | null
schemaToolSchema
valueunknown

In depth

A provider declaring no structured output is refused before the request. Sending it anyway and hoping the text parses is the silent-downgrade failure wearing a different hat: it works often enough to ship and fails on the input nobody tested.