When using the outputConfig(Class<T>) overload to generate a structured message schema, there is no way to specify other configuration options. Most namely, there is no way to set the effort option that is also specified through OutputConfig. It is forced to be unset, since schema generation calls the OutputConfig builder directly.
|
/** |
|
* Sets the output configuration with a JSON schema format derived from the structure of the |
|
* given class. This is the recommended way to specify structured outputs. |
|
* |
|
* Unlike the beta version, this GA version does NOT auto-inject any beta header. |
|
* |
|
* @see MessageCreateParams.Builder.outputConfig |
|
*/ |
|
@JvmOverloads |
|
fun outputConfig( |
|
outputType: Class<T>, |
|
localValidation: JsonSchemaLocalValidation = JsonSchemaLocalValidation.YES, |
|
) = apply { |
|
if (outputConfigSet) { |
|
throw IllegalArgumentException( |
|
"outputConfig was called multiple times. Please use only one outputConfig call." |
|
) |
|
} |
|
this.outputType = outputType |
|
val format = outputFormatFromClass(outputType, localValidation) |
|
paramsBuilder.outputConfig(OutputConfig.builder().format(format).build()) |
|
// GA version: NO beta header injection |
|
outputConfigSet = true |
When using the
outputConfig(Class<T>)overload to generate a structured message schema, there is no way to specify other configuration options. Most namely, there is no way to set the effort option that is also specified through OutputConfig. It is forced to be unset, since schema generation calls the OutputConfig builder directly.anthropic-sdk-java/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/StructuredMessageCreateParams.kt
Lines 187 to 209 in 2093447