Class ChatCompletionCreateParams.ResponseFormat
-
- All Implemented Interfaces:
public final class ChatCompletionCreateParams.ResponseFormatAn 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 JSON mode, which ensures the message the model generates is valid JSON.Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if
finish_reason="length", which indicates the generation exceededmax_tokensor the conversation exceeded the max context length.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceChatCompletionCreateParams.ResponseFormat.Visitorpublic final classChatCompletionCreateParams.ResponseFormat.Deserializerpublic final classChatCompletionCreateParams.ResponseFormat.Serializer
-
Method Summary
Modifier and Type Method Description final Optional<ResponseFormatText>text()final Optional<ResponseFormatJsonObject>jsonObject()final Optional<ResponseFormatJsonSchema>jsonSchema()final BooleanisText()final BooleanisJsonObject()final BooleanisJsonSchema()final ResponseFormatTextasText()final ResponseFormatJsonObjectasJsonObject()final ResponseFormatJsonSchemaasJsonSchema()final Optional<JsonValue>_json()final <T extends Any> Taccept(ChatCompletionCreateParams.ResponseFormat.Visitor<T> visitor)final ChatCompletionCreateParams.ResponseFormatvalidate()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ChatCompletionCreateParams.ResponseFormatofText(ResponseFormatText text)final static ChatCompletionCreateParams.ResponseFormatofJsonObject(ResponseFormatJsonObject jsonObject)final static ChatCompletionCreateParams.ResponseFormatofJsonSchema(ResponseFormatJsonSchema jsonSchema)-
-
Method Detail
-
text
final Optional<ResponseFormatText> text()
-
jsonObject
final Optional<ResponseFormatJsonObject> jsonObject()
-
jsonSchema
final Optional<ResponseFormatJsonSchema> jsonSchema()
-
isJsonObject
final Boolean isJsonObject()
-
isJsonSchema
final Boolean isJsonSchema()
-
asText
final ResponseFormatText asText()
-
asJsonObject
final ResponseFormatJsonObject asJsonObject()
-
asJsonSchema
final ResponseFormatJsonSchema asJsonSchema()
-
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)
-
ofJsonObject
final static ChatCompletionCreateParams.ResponseFormat ofJsonObject(ResponseFormatJsonObject jsonObject)
-
ofJsonSchema
final static ChatCompletionCreateParams.ResponseFormat ofJsonSchema(ResponseFormatJsonSchema jsonSchema)
-
-
-
-