Class ResponseTextConfig.Builder
-
- All Implemented Interfaces:
public final class ResponseTextConfig.BuilderA builder for ResponseTextConfig.
-
-
Method Summary
Modifier and Type Method Description final ResponseTextConfig.Builderformat(ResponseFormatTextConfig format)An object specifying the format that the model must output. final ResponseTextConfig.Builderformat(JsonField<ResponseFormatTextConfig> format)Sets Builder.format to an arbitrary JSON value. final ResponseTextConfig.Builderformat(ResponseFormatText text)Alias for calling format with ResponseFormatTextConfig.ofText(text).final ResponseTextConfig.Builderformat(ResponseFormatTextJsonSchemaConfig jsonSchema)Alias for calling format with ResponseFormatTextConfig.ofJsonSchema(jsonSchema).final ResponseTextConfig.Builderformat(ResponseFormatJsonObject jsonObject)Alias for calling format with ResponseFormatTextConfig.ofJsonObject(jsonObject).final <T extends Any> StructuredResponseTextConfig.Builder<T>format(Class<T> responseType, JsonSchemaLocalValidation localValidation)Sets the text configuration's format to a JSON schema derived from the structure of the given class. final <T extends Any> StructuredResponseTextConfig.Builder<T>format(Class<T> responseType)Sets the text configuration's format to a JSON schema derived from the structure of the given class. final ResponseTextConfig.Builderverbosity(ResponseTextConfig.Verbosity verbosity)Constrains the verbosity of the model's response. final ResponseTextConfig.Builderverbosity(Optional<ResponseTextConfig.Verbosity> verbosity)Alias for calling Builder.verbosity with verbosity.orElse(null).final ResponseTextConfig.Builderverbosity(JsonField<ResponseTextConfig.Verbosity> verbosity)Sets Builder.verbosity to an arbitrary JSON value. final ResponseTextConfig.BuilderadditionalProperties(Map<String, JsonValue> additionalProperties)final ResponseTextConfig.BuilderputAdditionalProperty(String key, JsonValue value)final ResponseTextConfig.BuilderputAllAdditionalProperties(Map<String, JsonValue> additionalProperties)final ResponseTextConfig.BuilderremoveAdditionalProperty(String key)final ResponseTextConfig.BuilderremoveAllAdditionalProperties(Set<String> keys)final ResponseTextConfigbuild()Returns an immutable instance of ResponseTextConfig. -
-
Method Detail
-
format
final ResponseTextConfig.Builder format(ResponseFormatTextConfig format)
An object specifying the format that the model must output.
Configuring
{ "type": "json_schema" }enables Structured Outputs, which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.The default format is
{ "type": "text" }with no additional options.Not recommended for gpt-4o and newer models:
Setting to
{ "type": "json_object" }enables the older JSON mode, which ensures the message the model generates is valid JSON. Usingjson_schemais preferred for models that support it.
-
format
final ResponseTextConfig.Builder format(JsonField<ResponseFormatTextConfig> format)
Sets Builder.format to an arbitrary JSON value.
You should usually call Builder.format with a well-typed ResponseFormatTextConfig value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
format
final ResponseTextConfig.Builder format(ResponseFormatText text)
Alias for calling format with
ResponseFormatTextConfig.ofText(text).
-
format
final ResponseTextConfig.Builder format(ResponseFormatTextJsonSchemaConfig jsonSchema)
Alias for calling format with
ResponseFormatTextConfig.ofJsonSchema(jsonSchema).
-
format
final ResponseTextConfig.Builder format(ResponseFormatJsonObject jsonObject)
Alias for calling format with
ResponseFormatTextConfig.ofJsonObject(jsonObject).
-
format
@JvmOverloads() final <T extends Any> StructuredResponseTextConfig.Builder<T> format(Class<T> responseType, JsonSchemaLocalValidation localValidation)
Sets the text configuration's format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredResponseTextConfig.Builder that will build a StructuredResponseTextConfig instance when
build()is called.- Parameters:
responseType- A class from which a JSON schema will be derived to define the text configuration's format.localValidation- JsonSchemaLocalValidation.YES (the default) to validate the JSON schema locally when it is generated by this method to confirm that it adheres to the requirements and restrictions on JSON schemas imposed by the OpenAI specification; or JsonSchemaLocalValidation.NO to skip local validation and rely only on remote validation.
-
format
@JvmOverloads() final <T extends Any> StructuredResponseTextConfig.Builder<T> format(Class<T> responseType)
Sets the text configuration's format to a JSON schema derived from the structure of the given class. This changes the builder to a type-safe StructuredResponseTextConfig.Builder that will build a StructuredResponseTextConfig instance when
build()is called.- Parameters:
responseType- A class from which a JSON schema will be derived to define the text configuration's format.
-
verbosity
final ResponseTextConfig.Builder verbosity(ResponseTextConfig.Verbosity verbosity)
Constrains the verbosity of the model's response. Lower values will result in more concise responses, while higher values will result in more verbose responses. Currently supported values are
low,medium, andhigh.
-
verbosity
final ResponseTextConfig.Builder verbosity(Optional<ResponseTextConfig.Verbosity> verbosity)
Alias for calling Builder.verbosity with
verbosity.orElse(null).
-
verbosity
final ResponseTextConfig.Builder verbosity(JsonField<ResponseTextConfig.Verbosity> verbosity)
Sets Builder.verbosity to an arbitrary JSON value.
You should usually call Builder.verbosity with a well-typed Verbosity value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
additionalProperties
final ResponseTextConfig.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
putAdditionalProperty
final ResponseTextConfig.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final ResponseTextConfig.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final ResponseTextConfig.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final ResponseTextConfig.Builder removeAllAdditionalProperties(Set<String> keys)
-
build
final ResponseTextConfig build()
Returns an immutable instance of ResponseTextConfig.
Further updates to this Builder will not mutate the returned instance.
-
-
-
-