'text': Plain text response (default) - standard conversational output
'json_object': JSON response - model attempts to return valid JSON, but without strict schema validation
AiStructuredOutputFormat: Structured output with schema (Anthropic only) - guarantees JSON conforms exactly to provided schema
Structured outputs (Anthropic-specific):
For Anthropic models that support structured outputs, you can pass an object with type: 'json_schema'
and a JSON schema. This uses constrained decoding to guarantee the response matches your schema perfectly,
eliminating parsing errors and validation issues.
Response format for AI agent responses.
Available formats:
'text': Plain text response (default) - standard conversational output'json_object': JSON response - model attempts to return valid JSON, but without strict schema validationAiStructuredOutputFormat: Structured output with schema (Anthropic only) - guarantees JSON conforms exactly to provided schemaStructured outputs (Anthropic-specific): For Anthropic models that support structured outputs, you can pass an object with
type: 'json_schema'and a JSON schema. This uses constrained decoding to guarantee the response matches your schema perfectly, eliminating parsing errors and validation issues.Example with structured output: