Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

StructuredOutputMiddlewareConfig.md

152 lines4.4 KB

Interface: StructuredOutputMiddlewareConfig

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:151

Config passed to onStructuredOutputConfig.

Extends ChatMiddlewareConfig with the outputSchema being sent to the provider. Middleware may transform the schema (e.g., inject $defs, strip vendor-incompatible keywords) by returning a partial that includes outputSchema.

Note: tools is structurally inherited from ChatMiddlewareConfig but is NOT forwarded to the structured-output adapter call — the final call is a single typed-response request, not an agentic loop. Returning a transformed tools array from onStructuredOutputConfig updates engine state but does not change what reaches the provider's structured-output endpoint.

Extends

Properties

maxTokens?

optional maxTokens: number;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:132

Inherited from

ChatMiddlewareConfig.maxTokens


messages

messages: ModelMessage<
  | string
  | ContentPart<unknown, unknown, unknown, unknown, unknown>[]
  | null>[];

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:127

Inherited from

ChatMiddlewareConfig.messages


metadata?

optional metadata: Record<string, unknown>;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:133

Inherited from

ChatMiddlewareConfig.metadata


modelOptions?

optional modelOptions: Record<string, unknown>;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:134

Inherited from

ChatMiddlewareConfig.modelOptions


outputSchema

outputSchema: JSONSchema;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:153

JSON Schema being sent to the provider for structured output.


systemPrompts

systemPrompts: SystemPrompt[];

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:128

Inherited from

ChatMiddlewareConfig.systemPrompts


temperature?

optional temperature: number;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:130

Inherited from

ChatMiddlewareConfig.temperature


tools

tools: Tool<SchemaInput, SchemaInput, string>[];

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:129

Inherited from

ChatMiddlewareConfig.tools


topP?

optional topP: number;

Defined in: packages/typescript/ai/src/activities/chat/middleware/types.ts:131

Inherited from

ChatMiddlewareConfig.topP