Class OpenAI
Convenience
quick Chat Response
Submit a single text prompt to ChatGPT conversations endpoint, and return only the message generated. Convenience method for single request prompts.
Parameters
- prompt: string
Text prompt to submit to ChatGPT
Optionaloptions: objectOptional key-value object specifying other options to include with the request, see Completion docs for supported options. Default
modelvalue isgpt-3.5-turbo
Returns string
- prompt: string
quick Code Edit
Submit a single text input and instructions to the Edits endpoint, using the
code-davinci-edit-001model to generate code or refactor, and return only the message generated.Parameters
- input: string
Text input to submit, generally used only if you are instruction the model to refactor existing code.
- instructions: string
Instructions to model
Optionaloptions: objectOptional key-value object specifying other options to include with the request, see Edit docs for supported options. Default
modelvalue istext-davinci-edit-001
Returns string
- input: string
quick Text Edit
Submit a single text input and instructions to the Edits endpoint, using the
text-davinci-edit-001model, and return only the message generated. Convenience method for single request input.Parameters
- input: string
Text input to submit
- instructions: string
Instructions to model
Optionaloptions: objectOptional key-value object specifying other options to include with the request, see Edit docs for supported options. Default
modelvalue istext-davinci-edit-001
Returns string
- input: string
Options
Optionalcredential Identifier
Optional identifier for API Key credentials. If an API Key is not provided as a parameter when instantiating the object, the user will be prompted to enter one of the first time they run an action requiring it. By default, these will be stored as OpenAI credentials. If you have the need to store multiple API Keys, or use the action with alternate compatible host services (like Perplexity.ai), you can set an alternate identifier for use with the Credential system. Default: OpenAI
model
Name of the model to use. Model can also be passed as a parameter in requests, but settings this to a supported model will make it the default model for requests using this instance. Default: gpt-3.5-turbo
Other
constructor
timeout
Time in seconds to wait for a request to receive a response from the server. Default: 120 seconds.
request
- request(
settings: {
data?: { [x: string]: string };
headers?: { [x: string]: string };
method: string;
parameters?: { [x: string]: string };
path: string;
},
): HTTPResponseExecute a request against the OpenAI API. For successful requests, the HTTPResponse object will contain an object or array or objects decoded from the JSON returned by OpenAI as appropriate to the request made. Refer to OpenAI API documentation for details about the expected parameters and responses.
Parameters
- settings: {
data?: { [x: string]: string };
headers?: { [x: string]: string };
method: string;
parameters?: { [x: string]: string };
path: string;
}Optionaldata?: { [x: string]: string }An object containing data to be encoded into the HTTP body of the request. Drafts will take care of the JSON conversion.
Optionalheaders?: { [x: string]: string }An object contain key-values to be added as custom headers in the request. There is no need to provide authorization headers, Drafts will add those.
method: string
The HTTP method, like "GET", "POST", etc.
Optionalparameters?: { [x: string]: string }An object containing key-values to be added to the request as URL parameters. Drafts will take care of encoding these.
path: string
The path to the API endpoint in the OpenAI API. This should include the path after the API version. For example
/chat/completion
Returns HTTPResponse
- settings: {
Staticcreate
Creates a new OpenAI object.
Parameters
OptionalapiKey: stringA valid OpenAI API Key. This value is optional, and if not provided, the default OpenAPI API key stored in Credentials will be used, or the user prompted to provide an API Key to store. Only provide a specific API Key if you desire to override the default.
Optionalhost: stringOptionally provide the API endpoint URL for any OpenAI API compatible endpoint, such as a custom Azure AI instance, or Perplexity.ai API. Defaults to
https://api.openai.com
Returns OpenAI

Script integration with OpenAI API. This object offers convenience over direct HTTP requests by:
Example
Translation
Direct API Request
Note that the
OpenAIobject can be used with any OpenAI API-compatible provider (such as Deep Seek) by overriding thehostparameter when constructing the object.