Spring AI provides Structured Output converters to transform LLM responses from raw Strings into structured data types like JSON, XML, or Java classes. The converter works by appending format instructions to the prompt and then parsing the model's response into the target type.
Available converter implementations include:
BeanOutputConverter<T>: Instructs the model to generate a JSON response matching a specific Java class (Bean) or ParameterizedTypeReference, then deserializes it using ObjectMapper.MapOutputConverter: Instructs the model to generate an RFC8259 compliant JSON response and converts it into a java.util.Map<String, Object>.ListOutputConverter: Instructs the model to generate comma-separated values and converts the output into a java.util.List.