OpenAI Component
Interact with OpenAI models, including Chat GPT and DALL·E
Component key: openai
Description
OpenAI is an artifical intelligence research laboratory that conducts AI research. It has notably produced the chat AI ChatGPT and the image generator DALL·E.
This component wraps some of OpenAI's REST API endpoints. Additional endpoints can be referenced in their API documentation. You can use the Raw Request action to interact with endpoints that are not convered by other actions.
Connections
OpenAI API Key
Integrations can authenticate with OpenAI using API keys. Generate an API key at platform.openai.com/account/api-keys.
If your user is associate with one organization, you can leave the connection's organization field blank. Otherwise, specify your organization's ID.
Input | Notes | Example |
---|---|---|
API Key password / Required apiKey | Generate an API key at https://platform.openai.com/account/api-keys | |
Organization string organization | Your organization ID. If you have just one organization, this value is optional. | org-9AeeV8Yj8WK9tW6QEZNHDI8Z |
Actions
Create Chat Completion
Create a completion for the chat message | key: createChatCompletion
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Messages code / Required messages | |||
Model string / Required model | gpt-3.5-turbo | text-davinci-003 | |
Number of choices string numChoices | 1 | How many chat completion choices to generate for each input message. | |
Temperature string temperature | 1 | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. | |
Timeout (ms) string timeout | 2000 | The maximum amount of time (in MS) to wait for a response. | 2000 |
top_p string topP | 1 | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. |
Example Payload for Create Chat Completion
{
"data": {
"id": "chatcmpl-6vf993Onyn1Bwq67AYDTR6fIjzvBu",
"object": "chat.completion",
"created": 1679200883,
"model": "gpt-3.5-turbo-0301",
"usage": {
"prompt_tokens": 56,
"completion_tokens": 21,
"total_tokens": 77
},
"choices": [
{
"message": {
"role": "assistant",
"content": "The 2020 World Series was played at the Globe Life Field in Arlington, Texas, USA."
},
"finish_reason": "stop",
"index": 0
}
]
}
}
Create Image
Create image(s) given a prompt | key: createImage
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Image Size string imageSize | 1024x1024 | The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. | |
Number of Images string / Required numImages | 1 | The number of images to generate. Must be between 1 and 10. | |
Prompt string / Required prompt | A text description of the desired image(s). The maximum length is 1000 characters. | A cute baby sea otter | |
Timeout (ms) string timeout | 2000 | The maximum amount of time (in MS) to wait for a response. | 2000 |
Example Payload for Create Image
{
"data": {
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
}
Get Model by ID
Get model by ID | key: getModelById
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Model string / Required model | text-davinci-003 | ||
Timeout (ms) string timeout | 2000 | The maximum amount of time (in MS) to wait for a response. | 2000 |
Example Payload for Get Model by ID
{
"data": {
"id": "davinci",
"object": "model",
"created": 1649359874,
"owned_by": "openai",
"permission": [
{
"id": "modelperm-U6ZwlyAd0LyMk4rcMdz33Yc3",
"object": "model_permission",
"created": 1669066355,
"allow_create_engine": false,
"allow_sampling": true,
"allow_logprobs": true,
"allow_search_indices": false,
"allow_view": true,
"allow_fine_tuning": false,
"organization": "*",
"group": null,
"is_blocking": false
}
],
"root": "davinci",
"parent": null
}
}
List Models
List all available models | key: listModels
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Timeout (ms) string timeout | 2000 | The maximum amount of time (in MS) to wait for a response. | 2000 |
Example Payload for List Models
{
"data": {
"object": "list",
"data": [
{
"id": "davinci",
"object": "model",
"created": 1649359874,
"owned_by": "openai",
"permission": [
{
"id": "modelperm-U6ZwlyAd0LyMk4rcMdz33Yc3",
"object": "model_permission",
"created": 1669066355,
"allow_create_engine": false,
"allow_sampling": true,
"allow_logprobs": true,
"allow_search_indices": false,
"allow_view": true,
"allow_fine_tuning": false,
"organization": "*",
"group": null,
"is_blocking": false
}
],
"root": "davinci",
"parent": null
}
]
}
}
Raw Request
Send raw HTTP request to OpenAI | key: rawRequest
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Data string data | The HTTP body payload to send to the URL. | {"exampleKey": "Example Data"} | |
Debug Request boolean debugRequest | false | Enabling this flag will log out the current request. | |
File Data string Key Value List fileData | File Data to be sent as a multipart form upload. | [{key: "example.txt", value: "My File Contents"}] | |
File Data File Names string Key Value List fileDataFileNames | File names to apply to the file data inputs. Keys must match the file data keys above. | ||
Form Data string Key Value List formData | The Form Data to be sent as a multipart form upload. | [{"key": "Example Key", "value": new Buffer("Hello World")}] | |
Header string Key Value List headers | A list of headers to send with the request. | User-Agent: curl/7.64.1 | |
Max Retry Count string maxRetries | 0 | The maximum number of retries to attempt. Specify 0 for no retries. | |
Method string / Required method | The HTTP method to use. | ||
Query Parameter string Key Value List queryParams | A list of query parameters to send with the request. This is the portion at the end of the URL similar to ?key1=value1&key2=value2. | ||
Response Type string / Required responseType | json | The type of data you expect in the response. You can request json, text, or binary data. | |
Retry On All Errors boolean retryAllErrors | false | If true, retries on all erroneous responses regardless of type. This is helpful when retrying after HTTP 429 or other 3xx or 4xx errors. Otherwise, only retries on HTTP 5xx and network errors. | |
Retry Delay (ms) string retryDelayMS | 0 | The delay in milliseconds between retries. This is used when 'Use Exponential Backoff' is disabled. | |
Timeout string timeout | The maximum time that a client will await a response to its request | 2000 | |
URL string / Required url | /v1/models | Input the path only (/v1/images/generations), The base URL is already included (https://api.openai.com). For example, to connect to https://api.openai.com/v1/images/generations, only /v1/images/generations is entered in this field. | /v1/images/generations |
Use Exponential Backoff boolean useExponentialBackoff | false | Specifies whether to use a pre-defined exponential backoff strategy for retries. When enabled, 'Retry Delay (ms)' is ignored. |