Skip to main content

Overview

Sometimes you want to define the extraction schema using one class but receive the result as a different class. This is useful when:
  • You have a rich domain model for the LLM schema but want a simpler DTO for output
  • You want to separate API contracts from internal representations
  • You need different validation rules for input vs output
The intoInstanceOf() method allows you to specify a different target class for deserialization while keeping the original class for schema generation.

Example

Expected Output

Note

The LLM receives the UserProfile schema (with 5 fields: name, age, email, phone, address), but the result is deserialized into UserDTO (with only 2 fields: name, email). Extra fields that don’t exist in UserDTO are ignored during deserialization.