ChatResponseChunk

data class ChatResponseChunk(val id: String, val created: Long, val choices: List<ChatChoiceChunk>)

The ChatResponseChunk contains all the data returned by the OpenAI Chat API. For most use cases, ChatResponseChunk.get (passing 0 to the index argument) is all you need.

This class is similar to ChatResponse, except with ChatResponseChunk you determine the number of generated tokens.

Since

1.2.0

See also

Constructors

Link copied to clipboard
constructor(id: String, created: Long, choices: List<ChatChoiceChunk>)

Create Chat response (for internal usage).

Functions

Link copied to clipboard
operator fun get(index: Int): ChatChoiceChunk

Shorthand for accessing the generated messages (shorthand for ChatResponseChunk.choices).

Link copied to clipboard

Returns the Instant time that the OpenAI Chat API sent this response. The time is measured as a unix timestamp (measured in seconds since 00:00:00 UTC on January 1, 1970).

Link copied to clipboard
fun getZonedTime(timezone: ZoneId = TimeZone.getDefault().toZoneId()): ZonedDateTime

Returns the time-zoned instant that the OpenAI Chat API sent this response. By default, this method uses the system's timezone.

Properties

Link copied to clipboard

The list of generated messages.

Link copied to clipboard

The Unix timestamp (measured in seconds since 00:00:00 UTC on January 1, 1970) when the API response was created.

Link copied to clipboard
val id: String

The unique id for your request.