openai.openai.createchatcompletion
Home > @runlightyear/openai > OpenAI > createChatCompletion
OpenAI.createChatCompletion() method
Given a chat conversation, the model will return a chat completion response.
Signature:createChatCompletion(props: CreateChatCompletionProps): Promise<CreateChatCompletionResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
props | CreateChatCompletionProps |
Promise<CreateChatCompletionResponse>
Example
Create a chat completion
const result = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{
role: "system",
content: "You are a helpful assistant.",
},
{
role: "user",
content: "Hello!",
},
],
});
const choice = result.data.choices[0];
const completion = choice.message.content;
console.log("Completion: ", completion);