ChatResponse

data class ChatResponse(val id: String, val created: Long, val choices: List<ChatChoice>, val usage: ChatUsage)

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

Constructors

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

Create Chat response (for internal usage).

Functions

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

Shorthand for accessing the generated messages (shorthand for ChatResponse.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.

Link copied to clipboard

The number of tokens used in this request/response.