OpenAI API
How to obtain OpenAI API credentials
Go to https://openai.com/
Org ID https://platform.openai.com/account/org-settings
API Key https://platform.openai.com/account/api-keys
FYI – below is what you would receive from chatGPT, if you ask, “show me how to use OpenAI API?” As you see this is all written for software developers (from #2 down) and is not easy to understand for non-programmers. For the Low-code Python users, you just need to do #1 and obtain API credentials from the OpenAI website and you are ready to use the popular feature of the OpenAI solution!
Prompt:
How do I use OpenAI API?
Answer:
To use the ChatGPT API, you'll need to make HTTP requests to the API endpoint. Here's a step-by-step guide on how to use the ChatGPT API:
- Obtain an API key: Visit the OpenAI website (openai.com) and navigate to the API section. Follow the instructions to sign up for an API key if you haven't already
- Set up your API environment: You can use any programming language that can make HTTP requests. Make sure you have the necessary libraries or tools to send HTTP requests. Popular choices include Python with libraries like `requests` or `curl` command-line tool.
- Make a POST request: Construct an HTTP POST request to the API endpoint `https://api.openai.com/v1/chat/completions`.
Set the headers: Include the following headers in your request:
- `'Content-Type': 'application/json'` - `'Authorization': 'Bearer YOUR_API_KEY'` (Replace `YOUR_API_KEY` with the actual API key you obtained earlier)
Define the payload: In the body of your request, pass a JSON object with the following parameters:
- `'model': 'gpt-3.5-turbo'` (specifies the model to use) - `'messages'`: an array of message objects containing the conversation history. Each message object should have a `'role'` (either "system", "user", or "assistant") and a `'content'` (the content of the message). Here's an example of a payload JSON object: ```json { 'model': 'gpt-3.5-turbo', 'messages': [ {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': 'Who won the world series in 2020?'}, {'role': 'assistant', 'content': 'The Los Angeles Dodgers won the World Series in 2020.'} ] } ```
- Send the request: Send the POST request to the API endpoint with the headers and payload you defined.
- Handle the response: The API will respond with a JSON object containing the assistant's reply. Extract the response from the JSON and use it in your application.
Please note that usage of the OpenAI API may involve costs, so make sure to review the pricing and terms on the OpenAI website.
It's important to refer to the official OpenAI API documentation for more detailed information, including any updates or changes since my knowledge cutoff date.
Sample Bot
OpenAI API sample bot is available from here
Now how to set up the plugin parameters
Function: Chat (with Prompt)
Required input
- Org ID
- API Key
- Choose function = Chat
Advanced input (required)
- Model name (gpt-3.5-turbo for free account and gpt-4 for paid account)
- Prompt (your question – it is required to be in one line)
Advanced input (optional)
- Is Text Out – unchecked will receive JSON output, checked will give TXT output
Return Value
API returns the answer to your question (prompt) (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: Chat (with YAML file)
Required input
- Org ID
- API Key
- Choose function = Chat
Advanced input (required)
- Model name (gpt-3.5-turbo for free account and gpt-4 for paid account)
- YAML file with a format which is explained here
Example: YAML should look like this –
- role: system content: You are a helpful assistant. - role: user content: Who won the world series in 2020? - role: assistant content: The Los Angeles Dodgers won the World Series in 2020.
Advanced input (optional)
- Is Text Out – this will output only the text part of the API response.
Return Value
API returns the answer to your question (prompt) (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: Chat (with Reference Text File)
Required input
- Org ID
- API Key
- Choose function = Chat
Advanced input (required)
- Model name (gpt-3.5-turbo for free account and gpt-4 for paid account)
- Reference Text File without any specific format
- Prompt – your question about the Reference File
Advanced input (optional)
- Is Text Out – this will output only the text part of the API response.
Return Value
API returns the answer to your question (prompt) (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: Gen Image (generate image)
Required input
- Org ID
- API Key
- Choose function = Gen Images
Advanced input (required)
- Prompt – your request for the image to be generated by OpenAI
- Num Images – number of images you request OpenAI to generate – in integer
- Img Size – size of the images of your request – choose from the pull-down menu
- Img prefix – the output image files will contain this prefix in their file names
Advanced input (optional)
- None
Return Value
API returns the file names of your image files (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: Speech-To-Text (STT)
Required input
- Org ID
- API Key
- Choose function = Speech to Text
Advanced input (required)
- Voice file – audio file in format of WAV and mp3
Advanced input (optional)
- Is Text Out – unchecked will give JSON, checked will output TXT
Return Value
API returns the file names of your image files (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: List Models
This function simply returns the latest list of OpenAI’s active models
Required input
- Org ID
- API Key
- Choose function = List Model
Advanced input (required)
- None
Advanced input (optional)
- None
Return Value
API returns the list of OpenAI models (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
Function: Model Info
This function simply returns information about a specific model
Required input
- Org ID
- API Key
- Choose function = List Model
Advanced input (required)
- Model Name
Advanced input (optional)
- None
Return Value
API returns the information of the model (model name) (String, CSV, or File)
Return Code
- 0 - Success
- 1 - Invalid Argument – such as no API key found
- 2 - Invalid file – no prompt, incorrect reference file
- 99 - Everything else
- ABBYY Download
- ABBYY Status
- ABBYY Upload
- AD LDAP
- Adv Send Email
- API Requests
- ARGOS API
- Arithmetic Op
- ASCII Converter
- Attach Image
- AWS S3
- AWS Textra Rekog
- Base64
- Basic Numerical Operations
- Basic String Manipulation
- Bot Collabo
- Box
- Box II
- Chatwork GetMessage
- Chatwork Notification
- Citizen Log
- Clipboard
- Codat API
- Convert CharSet
- Convert Image
- Convert Image II
- Create Newfile
- CSV2XLSX
- Data Plot I
- DeepL Free
- Detect CharSet
- Dialog Calendar
- Dialog Error
- Dialog File Selection
- Dialog Forms
- Dialog Info
- Dialog Password
- Dialog Question
- Dialog Text Entry
- Dialog Text Info
- Dialog Warning
- DirectCloud API
- Doc2TXT
- DocDigitizer Get Doc
- DocDigitizer Tracking
- DocDigitizer Upload
- Docker Remote Service
- Drag and Drop
- Dropbox
- Dynamic Python
- Email IMAP ReadMon
- Email Read Mon
- Env Check
- Env Var
- Excel2Image
- Excel Advanced
- Excel Advance IV
- Excel AdvII
- Excel AdvIII
- Excel Copy Paste
- Excel Formula
- Excel Large Files
- Excel Macro
- Excel Newfile
- Excel Simple Read
- Excel Simple Write
- Excel Style
- Excel Update
- Fairy Devices mimi AI
- File Conv
- File Downloader
- File Folder Exists
- File Folder Op
- File Status
- Fixed Form Processing
- Floating Form Processing
- Folder Monitor
- Folder Status
- Folder Structure
- FTP Server
- Git HTML Extract
- Google Calendar
- Google Cloud Vision API
- Google Drive
- Google Search API
- Google Sheets
- Google Token
- Google Translate
- Google TTS
- GraphQL API
- Html Extract
- HTML Table
- IBM Speech to Text
- IBM Visual Recognition
- Java UI Automation
- JP Holiday
- JSON Select
- JSON to from CSV
- Lazarus Forms
- Lazarus Invoices
- Lazarus RikAI
- Lazarus Riky
- LINE ID Card OCR
- LINE Notify
- LINE Receipt OCR
- Microsoft Teams
- MongoDB
- MQTT Publisher
- MS Azure Text Analytics
- MS Word Extract
- NAVER OCR
- Newuser-SFDC
- OCI
- OCR PreProcess
- OpenAI API
- Oracle SQL
- Outlook
- Outlook Email
- PANDAS I
- pandas II
- pandas III
- PANDAS profiling
- Parsehub
- Password Generate
- Path Manipulation
- PDF2Doc
- PDF2Table
- PDF2TXT
- PDF Miner
- PDF SplitMerge
- PostgreSQL
- PowerShell
- PPTX Template
- Print 2 Image
- Python Selenium
- QR Generate
- QR Read
- RakurakuHanbai API
- Regression
- Rename File
- REST API
- Rossum
- Running GAS
- Scrapy Basic
- Screen Capture
- Screen Recording START
- Screen Recording STOP
- Screen Snipping
- Seaborn Plot
- SharePoint
- Simple Counter
- Simple SFDC
- Slack
- Sort CSV
- Speed Test
- SQL
- SQLite
- SSH Command
- SSH Copy
- String Manipulation
- String Similarity
- Svc Check
- Sys Info
- Telegram
- Tesseract
- Text2PDF
- Text2Word
- Text Read
- Text Write
- Time Diff
- Time Stamp
- Web Extract
- Windows Op
- Windows Screen Lock
- Win UI Control
- Win UI Text
- Word2PDF
- Word2TXT
- Word Editor
- Work Calendar
- XML Extract
- XML Manipulation
- Xtracta Get Doc
- Xtracta Tracking
- Xtracta Upload
- YouTube Operation
- ZipUnzip