Skip to content

schemaPrompt

function schemaPrompt(schema): string;

Defined in: core/src/schema.ts:103

The schema as prompt text, for a shape that cannot enforce one.

The seam’s promise is that a provider without native enforcement gets the schema in the PROMPT instead. Skip it and an opts.json request goes out carrying nothing about the shape at all: the model answers in whatever form it likes, and the caller’s JSON.parse throws on the happy path, where no retry looks and no error is recorded.

Two shapes need it, which is why the wording lives here rather than in one of them. Anthropic has never had a schema mode. The OpenAI dialect falls back to plain JSON mode on every gateway: json_object asks for valid JSON and says nothing whatsoever about its shape.

Parameter Type
schema unknown

string