chatCompletions

Sends a request to the OpenAI API to generate a chat completion.

Return

a Flow of ChatCompletionResponse representing the chat completions generated by the API.

Example usage:

val client = OpenAIClient("<API_KEY>")
val chatRequest = ChatCompletionRequest("<Chat request parameters>")
val chatCompletionsFlow = client.chatCompletions(chatRequest)
chatCompletionsFlow.collect { response ->
println("Chat completion: ${response.text}")
}

Parameters

request

The chat completion request to be sent to the API. This object contains parameters for the chat completion, such as the prompt and other model settings.