Returns a Runnable that forces the model to produce output conforming
to outputSchema (a Zod schema or plain JSON Schema object).
The extraction strategy (JSON Schema response format, function calling,
or JSON mode) is chosen automatically based on model capabilities —
see resolveOpenRouterStructuredOutputMethod. You can override
this via config.method.
When config.includeRaw is true the returned object contains both
the raw BaseMessage and the parsed output, with a fallback that
sets parsed: null if the parser throws.
withStructuredOutput<
RunOutput extends Record<string, any> = Record<string, any>
>(
outputSchema: Record<string, any> | InteropZodType<RunOutput>,
config: StructuredOutputMethodOptions<false>
): Runnable<BaseLanguageModelInput, RunOutput>| Name | Type | Description |
|---|---|---|
outputSchema* | Record<string, any> | InteropZodType<RunOutput> | |
config | StructuredOutputMethodOptions<false> |