Class ChatCompletionCreateParams.ResponseFormat
-
- All Implemented Interfaces:
public final class ChatCompletionCreateParams.ResponseFormat
An object specifying the format that the model must output.
Setting to
{ "type": "json_schema", "json_schema": {...} }
enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.Setting to
{ "type": "json_object" }
enables the older JSON mode, which ensures the message the model generates is valid JSON. Usingjson_schema
is preferred for models that support it.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ChatCompletionCreateParams.ResponseFormat.Visitor
An interface that defines how to map each variant of ResponseFormat to a value of type T.
-
Method Summary
-
-
Method Detail
-
text
final Optional<ResponseFormatText> text()
Default response format. Used to generate text responses.
-
jsonSchema
final Optional<ResponseFormatJsonSchema> jsonSchema()
JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
jsonObject
final Optional<ResponseFormatJsonObject> jsonObject()
JSON object response format. An older method of generating JSON responses. Using
json_schema
is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.
-
isJsonSchema
final Boolean isJsonSchema()
-
isJsonObject
final Boolean isJsonObject()
-
asText
final ResponseFormatText asText()
Default response format. Used to generate text responses.
-
asJsonSchema
final ResponseFormatJsonSchema asJsonSchema()
JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
asJsonObject
final ResponseFormatJsonObject asJsonObject()
JSON object response format. An older method of generating JSON responses. Using
json_schema
is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.
-
accept
final <T extends Any> T accept(ChatCompletionCreateParams.ResponseFormat.Visitor<T> visitor)
-
validate
final ChatCompletionCreateParams.ResponseFormat validate()
-
ofText
final static ChatCompletionCreateParams.ResponseFormat ofText(ResponseFormatText text)
Default response format. Used to generate text responses.
-
ofJsonSchema
final static ChatCompletionCreateParams.ResponseFormat ofJsonSchema(ResponseFormatJsonSchema jsonSchema)
JSON Schema response format. Used to generate structured JSON responses. Learn more about Structured Outputs.
-
ofJsonObject
final static ChatCompletionCreateParams.ResponseFormat ofJsonObject(ResponseFormatJsonObject jsonObject)
JSON object response format. An older method of generating JSON responses. Using
json_schema
is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.
-
-
-
-