Chat Completion
Once you initialized the client and stored it as a variable, we can simply use the TextCompletion function in the client like this:
local response = client.ChatCompletion({
messages = {
{
role = 'system',
content = 'You are an helpful assistant.'
},
{
role = 'user',
content = 'Who are you?'
}
}
})
The response variable will contain the following:
Used model "response.model" (string)
The first choice "response.choice" (table)
The first choice's message object "response.choice_message" (table)
Token usage "response.usage" (table)
Last updated
Was this helpful?