openai.openai.createcompletion
Home > @runlightyear/openai > OpenAI > createCompletion
OpenAI.createCompletion() method
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
Signature:createCompletion(props: CreateCompletionProps): Promise<CreateCompletionResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
props | CreateCompletionProps |
Promise<CreateCompletionResponse>
Example
Create a completion
const result = await openai.createCompletion({
model: "text-davinci-003",
prompt: "Say this is a test",
maxTokens: 7,
temperature: 0,
});
const choice = result.data.choices[0];
const completion = choice.text;
console.log("Completion: ", completion);