"OpenAI" (Service Connection)
Use the OpenAI API with the Wolfram Language.
Connecting & Authenticating
Requests
Text
"Completion" — create text completion for a given prompt
"Prompt" | Automatic | the prompt for which to generate completions | |
"N" | Automatic | number of completions to return | |
"Temperature" | Automatic | sampling temperature (between 0 and 2) | |
"Echo" | Automatic | include the prompt in the completion | |
"MaxTokens" | Automatic | maximum number of tokens to generate | |
"Suffix" | Automatic | suffix that comes after a completion | |
"StopTokens" | None | up to four strings where the API will stop generating further tokens | |
"Model" | Automatic | name of the model to use | |
"FrequencyPenalty" | Automatic | penalize tokens based on their existing frequency in the text so far (between -2 and 2) | |
"PresencePenalty" | Automatic | penalize new tokens based on whether they appear in the text so far (between -2 and 2) | |
"LogProbs" | Automatic | include the log probabilities on the most likely tokens, as well as the chosen tokens (between 0 and 5) | |
"TotalProbabilityCutoff" | None | an alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with the requested probability mass | |
"BestOf" | Automatic | number of completions to generate before selecting the "best" | |
"User" | Automatic | unique identifier representing the end user | |
"Stream" | Automatic | return the result as server-sent events |
"Chat" — create a response for the given chat conversation
"Messages" | {} | a list of messages in the conversation, each given as an association with "role" and "content" keys | |
"N" | Automatic | number of chat completions to return | |
"Temperature" | Automatic | sampling temperature (between 0 and 2) | |
"MaxTokens" | Automatic | maximum number of tokens to generate | |
"Suffix" | Automatic | suffix that comes after a completion | |
"StopTokens" | None | up to four strings where the API will stop generating further tokens | |
"Model" | Automatic | name of the model to use | |
"FrequencyPenalty" | Automatic | penalize tokens based on their existing frequency in the text so far (between -2 and 2) | |
"PresencePenalty" | Automatic | penalize new tokens based on whether they appear in the text so far (between -2 and 2) | |
"LogProbs" | Automatic | include the log probabilities on the most likely tokens, as well as the chosen tokens (between 0 and 5) | |
"TotalProbabilityCutoff" | None | an alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with the requested probability mass | |
"User" | Automatic | unique identifier representing the end user | |
"Stream" | Automatic | return the result as server-sent events |
"Edit" — create a new edit for the provided input and instruction
"Input" | Automatic | text to edit | |
"Instruction" | "" | instruction for how to edit the prompt | |
"N" | Automatic | number of edits to return | |
"Temperature" | Automatic | sampling temperature (between 0 and 2) | |
"Model" | Automatic | name of the model to use | |
"TotalProbabilityCutoff" | Automatic | an alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with the requested probability mass | |
"User" | Automatic | unique identifier representing the end user |
"Embedding" — create an embedding vector representing the input text
"Input" | "" | one or a list of texts to get embeddings for | |
"Model" | Automatic | name of the model to use | |
"User" | Automatic | unique identifier representing the end user |
Image
"ImageCreate" — create a square image given a prompt
"Prompt" | Automatic | text description of the desired image | |
"N" | Automatic | number of images to generate | |
"Size" | Automatic | size of the generated image | |
"User" | Automatic | unique identifier representing the end user | |
"Model" | Automatic | name of the model to use | |
"Quality" | Automatic | control the quality of the result; possible values include "hd" | |
"Style" | Automatic | style of generated images; possible values include "vivid" or "natural" |
"ImageVariation" — create a variation of a given image
"Image" | (required) | image to use as the basis for the variation | |
"N" | Automatic | number of images to generate | |
"Size" | Automatic | size of the generated image | |
"User" | Automatic | unique identifier representing the end user |
"ImageEdit" — create an edited image given an original image and a prompt
"Image" | (required) | image to edit; requires an alpha channel if a mask is not provided | |
"Mask" | None | additional image whose fully transparent areas indicate where the input should be edited | |
"Prompt" | None | text description of the desired image edit | |
"N" | Automatic | number of images to generate | |
"Size" | Automatic | size of the generated image | |
"User" | Automatic | unique identifier representing the end user |
Audio
"AudioTranscription" — transcribe an audio recording into the input language
"Audio" | (required) | the Audio object to transcribe | |
"Language" | Automatic | language of the input audio | |
"Prompt" | None | optional text to guide the model's style or continue a previous audio segment | |
"Temperature" | Automatic | sampling temperature (between 0 and 1) | |
"Model" | Automatic | name of the model to use |
"AudioTranslation" — translate an audio recording into English
"Audio" | (required) | the Audio object to translate | |
"Prompt" | None | optional text to guide the model's style or continue a previous audio segment | |
"Temperature" | Automatic | sampling temperature (between 0 and 1) | |
"Model" | Automatic | name of the model to use |
"SpeechSynthesize" — synthesize speech from text
"Input" | (required) | the text to synthesize | |
"Voice" | Automatic | the voice to use for the synthesis | |
"Speed" | Automatic | the speed of the produced speech | |
"Model" | Automatic | name of the model to use |
Model Lists
"ChatModelList" — list models available for the "Chat" request
"ModerationModelList" — list models available for the "Moderation" request
"ImageModelList" — list models available for the image-related requests
"SpeechSynthesizeModelList" — list models available for the "SpeechSynthesize" request
Moderation
"Moderation" — classify if text violates OpenAI's Content Policy
"Input" | (required) | the text to classify | |
"Model" | Automatic | name of the model to use |