Interface ChatClient.EntityParamSpec

All Known Implementing Classes:
DefaultChatClient.DefaultEntityParamSpec
Enclosing interface:
ChatClient

public static interface ChatClient.EntityParamSpec
Configures optional behaviour for entity(...) calls. Options may be combined.
  • Method Details

    • useProviderStructuredOutput

      ChatClient.EntityParamSpec useProviderStructuredOutput()
      Delivers the JSON schema to the AI provider as an API-level constraint rather than appending it as prompt text. Has no effect if the underlying ChatModel does not support StructuredOutputChatOptions.

      Not enabled by default because native structured output support varies across models and providers. Known limitations:

      • Ollama: models with a built-in reasoning/thinking mode (e.g. qwen3:8b, qwen3.5:9b) may return plain text instead of JSON, causing deserialization failures. Use validateSchema() alongside this option for automatic retry, or switch to a non-reasoning model such as llama3.1:latest.
      • OpenAI: the Structured Outputs API does not accept a top-level JSON array schema. Requesting a List<T> with this option enabled will fail. Wrap the list in a container record or use the default prompt-based approach instead.
    • validateSchema

      ChatClient.EntityParamSpec validateSchema()
      Validates the model's JSON response against the entity schema and retries with the error feedback on failure, up to maxRepeatAttempts times (default: 3). Streaming is not supported.