v2026.5.3
All Bundles
Bundle Support for legacy OpenAI chat APIs (-lib openai)

Completion

Model response for a given text or image query

Inherits: EndPoint

Operations

Complete # function

Model response for the given query

function : Complete(model:String, message:Pair<String,String>, token:String) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagePair<String,String>completion message and image query.
tokenStringAPI token

Return

TypeDescription
Completioncompletion response

Example

token := "sk-...";
msg := Pair->New("user", "What is the speed of light?")<String, String>;
result := Completion->Complete("gpt-4o-mini", msg, token);
choice := result->GetFirstChoice();
choice->GetMessage()->GetSecond()->PrintLine();

Complete # function

Model response for the given query

function : Complete(model:String, message:Pair<String,String>, max_tokens:Int, temperature:Float, top_p:Float, token:String) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagePair<String,String>completion message and image query
max_tokensIntmaximum number of completion tokens returned by the API
temperatureFloatamount of randomness in the response, valued between 0 inclusive and 2 exclusive
top_pFloatnucleus sampling threshold, valued between 0 and 1 inclusive
tokenStringAPI token

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given query

function : Complete(model:String, messages:Vector<Pair<String,String>>) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagesVector<Pair<String,String>>list of messages comprising the conversation

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given query

function : Complete(model:String, messages:Vector<Pair<String,String>>) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagesVector<Pair<String,String>>list of messages comprising the conversation

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given image and query

function : Complete(model:String, message:Pair<String,API.OpenAI.ImageQuery>, token:String) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagePair<String,APIOpenAIImageQuery>completion message and image query.
tokenStringAPI token

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given image and query

function : Complete(model:String, message:Pair<String,API.OpenAI.ImageQuery>, max_tokens:Int, temperature:Float, top_p:Float, token:String) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagePair<String,APIOpenAIImageQuery>completion message and image query
max_tokensIntmaximum number of completion tokens returned by the API
temperatureFloatamount of randomness in the response, valued between 0 inclusive and 2 exclusive
top_pFloatnucleus sampling threshold, valued between 0 and 1 inclusive
tokenStringAPI token

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given image and query

function : Complete(model:String, messages:Vector<Pair<String,API.OpenAI.ImageQuery>>) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagesVector<Pair<String,APIOpenAIImageQuery>>list of messages comprising the conversation

Return

TypeDescription
Completioncompletion response

Complete # function

Model response for the given image and query

function : Complete(model:String, messages:Vector<Pair<String,API.OpenAI.ImageQuery>>) ~ Completion

Parameters

NameTypeDescription
modelStringID of the model to use
messagesVector<Pair<String,APIOpenAIImageQuery>>list of messages comprising the conversation

Return

TypeDescription
Completioncompletion response

GetChoices #

List of chat completion choices

method : public : GetChoices() ~ Vector<API.OpenAI.Chat.Choice>

Return

TypeDescription
Vector<APIOpenAIChatChoice>completion choices

Example

choices := result->GetChoices();
each(choice in choices) {
  choice->GetMessage()->GetSecond()->PrintLine();
};

GetCreatedAt #

Unix timestamp (in seconds) of when the object instance was created

method : public : GetCreatedAt() ~ Int

Return

TypeDescription
Inttime with the object instance was created

GetFirstChoice #

List of chat completion choices

method : public : GetFirstChoice() ~ API.OpenAI.Chat.Choice

Return

TypeDescription
Choicecompletion choices

Example

choice := result->GetFirstChoice();
role := choice->GetMessage()->GetFirst();
text := choice->GetMessage()->GetSecond();
"{$role}: {$text}"->PrintLine();

GetId #

Get object instance API ID

method : public : GetId() ~ String

Return

TypeDescription
Stringinstance ID

GetModel #

ID of the model to use

method : public : GetModel() ~ String

Return

TypeDescription
StringID of the model to use

GetObject #

Get the object type

method : public : GetObject() ~ String

Return

TypeDescription
Stringobject type

ToString #

String representation of the object

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation