
Last time we looked at the manual use of generative AI in accounting. We noted the limitations of manual use in larger-scale accounting operations. As such we recommended using custom application programming interface (API) scripts and plugins where and when manual operations can become tedious.
On the one hand, custom API scripts are pieces of code, e.g., Python or PHP, that you can write and execute through the OpenAI API or in the OpenAI Playground. You can also use custom API scripts to access external data sources or services, such as web scraping, databases, or other APIs. Also, they allow you to customize the behaviour and output of ChatGPT by using various parameters, such as temperature, frequency_penalty, presence_penalty, stop, and logprobs. Custom API scripts give you more flexibility and control over how ChatGPT responds to your queries, but they also require more technical skills and effort to write and maintain.
On the other hand, plugins are pre-built, ready-made/off-the-shelf APIs you can enable within ChatGPT without writing any code. They are designed to add specific functionality or knowledge to ChatGPT, such as accounting, weather, translation, math, trivia, &c. Plugins are created and maintained by OpenAI or third-party developers, and they are available in the ChatGPT marketplace. Plugins make it easier and faster to enhance ChatGPT with useful features. Still, they also have some limitations, such as dependency on external services, compatibility issues, or lack of customization options.
Custom API Scripts vs Plugins
To restate the case, both custom API scripts and plugins can be useful for different purposes and scenarios, depending on your needs and preferences. Some of the advantages and disadvantages of each approach are:
· Custom API scripts
o Advantages: more flexibility, control, and creativity; can access any data source or service; can fine-tune ChatGPT’s parameters and output
o Disadvantages: more technical skills and effort required; need to handle errors and exceptions; need to update and test the code regularly
· Plugins
o Advantages: easy and fast to use; no coding required; can leverage existing integrations and features; can discover and try new plugins in the marketplace
o Disadvantages: less flexibility and control; dependent on external services and developers; may have compatibility or quality issues; may not have the desired functionality or knowledge
In terms of scalability, both custom API scripts and plugins can be used to handle large volumes of requests and users, as long as they are optimized and reliable. However, custom API scripts may have further potential for scaling, as they can be adapted and improved to suit different use cases and scenarios, while plugins may have more constraints and limitations regarding functionality and performance, according to vendor specifications.
One use case that is a mainstay for accountants is the preparation and manipulation of data for analysis and another is the analysis of financial statements. To be able to gain the assistance of ChatGPT for these use cases the relevant information must be uploaded to the system. A caveat must be repeated, data uploaded to ChatGPT potentially can leak to the large language model (LLM,) and thus become available to other usersa serious risk to privacy and confidentiality. Consequently, we will demonstrate the use of a script and in this case the procedure of a custom API script, using Python, that retrieves a file, maybe journal entries, from a folder on the computer and uploads it to ChatGPT for query via prompting. Again, ChatGPT 4.0 provides native means to upload files.
A Python script that would retrieve a file from a folder on a computer and upload it to ChatGPT, skimpily, requires the following steps:1. Import the necessary Python modules, such as os (a built-in module that provides functions for interacting with the operating system, such as creating and managing files and directories, executing commands, accessing environment variables, and getting system information,) requests (library that allows you to send HTTP requests and interact with web services,) and shutil (a library that provides high-level operations on files and collections of files, such as copying, moving, deleting, archiving, and compressing.)
2. Define the path of the folder where the file is located and the name of the file you want to retrieve.
3. Use the os.path.join function to create the full path of the file, and check if it exists using the os.path.isfile function.
4. Use the requests.post function to send a POST request to the ChatGPT API endpoint, with the file as the data parameter, and your account credentials as the auth parameter.
5. Check the status code and the response text of the request, and handle any errors or exceptions that may occur.
6. Optionally, you can use the shutil.move function to move the file to another folder after uploading it to ChatGPT, or delete it using the os.remove function.
Python API Script
For the technically minded, here is how the script might look:Python
# Import the modules
import os
import requests
import shutil
# Define the folder path and the file name
folder_path =
"/path/to/folder"
file_name =
"example.txt"
# Create the full file path
file_path = os.path.join (folder_path, file_name)
# Check if the file exists
if os.path.isfile (file_path):
# Send a POST request to the ChatGPT API endpoint
url =
"https://chat.openai.com/api/v1/files/upload"
auth = (
"sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
# Replace with your ChatGPT API key
data =
open(file_path,
"rb")
# Open the file in binary mode
response = requests.post (url, data=data, auth=auth)
# Send the request
# Check the status code and the response text
if
response.status_code ==
200:
(
"File uploaded successfully.")
(response.text)
else
:
(
"File upload failed.")
(response.text)
# Close the file
data.close ()
# Optionally, move or delete the file
# new_folder_path = "/path/to/new/folder"
# shutil.move (file_path, new_folder_path) # Move the file
# os.remove (file_path) # Delete the file
else:
(
"File not found.")
Python Code Execution

Code Interpreter is a feature in ChatGPT that allows you to run Python code in a live working environment. It’s a sandboxed Python environment where you can execute Python code to perform any task you like, such as data analysis, visualization, coding, math, &c. You can also upload and download files to and from ChatGPT with Code Interpreter. This feature is exclusive to ChatGPT Plus subscribers and is currently in beta. You can learn more about it from these web sources
To access it, you need to enable it from the beta features section in your settings:· Open ChatGPT and log in to your account.
· Open “Settings” from the bottom-left corner.
· Move to “Beta features” and enable the “Code interpreter” toggle.
Once you have enabled the code interpreter, you can use it by typing %% followed by the Python code you want to run. For example, %%print(“Hello, world!”) will print “Hello, world!” in the chat. You can also upload and download files to and from ChatGPT with Code Interpreter.ChatGPT plugins are tools that help language models access up-to-date information, run computations, or use third-party services. They enhance ChatGPT’s capabilities and allow it to perform a wide range of actions, such as retrieving real-time information, retrieving knowledge-base information, or assisting users with actions.
You can source plugins for ChatGPT from the ChatGPT UI, where you can browse the Plugin Store and enable the plugins you want to use. You can also develop your plugin by following the documentation and registering your plugin in the ChatGPT UI.
QuickBooks For ChatGPT
For example, there is a QuickBooks (accounting software) Online plugin for ChatGPT. It allows you to connect your QuickBooks Online account with ChatGPT and access your accounting data, such as invoices, bills, customers, and reports. You can also create, update, or delete transactions using natural language commands. For example, you can say:
· Show me the balance sheet for the last quarter.
· Create an invoice for John Smith for $500.
· Mark bill #123 as paid.
You can get the QuickBooks Online plugin for ChatGPT from Zapier or consider the Plugin Store in the ChatGPT UI. You can also find more information about the plugin and how to use it in the documentation. The QuickBooks Online plugin allows you to access and manage your accounting data using natural language commands.
To use the QuickBooks Online plugin, you need to enable it in the ChatGPT UI and authenticate your QuickBooks Online account, so:
· In the ChatGPT UI start a new chat with GPT-4.[T1]
· Select the Plugins mode from the dropdown menu next to GPT-4.
· Click on the dropdown menu next to No Plugins enabled and choose Plugin Store.
· Find the QuickBooks Online plugin and click on the Enable button.
· Authenticate your QuickBooks Online account by following the instructions on the screen.
· You can now use the QuickBooks Online plugin in your ChatGPT conversations.
QuickBooks Example Use in ChatGPT
To create an invoice using natural language commands with the QuickBooks Online plugin for ChatGPT. Here are the steps you need to follow as suggested by Microsoft Copilot:
· Start a new chat with GPT-4 and select the Plugins mode from the dropdown menu next to GPT-4.
· Click on the dropdown menu next to No plugins enabled and choose QuickBooks Online.
· You can now use natural language commands to create an invoice. For example, you can say:
Create an invoice for John Smith for $500 for web design services
· ChatGPT will then create an invoice for John Smith with the specified amount and description and show you a preview of the invoice. You can also add more details to the invoice, such as due date, tax rate, or discount, by using natural language commands. For example, you can say:
Set the due date to March 15, 2024
Apply a 10% discount
Add a 5% tax rate
· ChatGPT will then update the invoice with the new information and show you the updated preview. You can also edit or delete any information by using natural language commands. For example, you can say:
Change the amount to $600
Remove the discount
· ChatGPT will then make the changes and show you the final preview of the invoice. You can also ask ChatGPT to show you the invoice details, such as invoice number, customer name, or total amount, by using natural language commands. For example, you can say:
What is the invoice number?
Who is the customer?
What is the total amount?
· ChatGPT will then answer your questions and show you the relevant information. You can also ask ChatGPT to perform other actions, such as sending the invoice to the customer, saving the invoice as a draft, or printing the invoice, by using natural language commands. For example, you can say:
Send the invoice to john.smith@email.com
Save the invoice as a draft
Print the invoice
· ChatGPT will then execute your commands and confirm the actions. You can also ask ChatGPT to show you the status of the invoice, such as sent, paid, or overdue, by using natural language commands. For example, you can say:
Is the invoice paid?
How long is the invoice overdue?
· ChatGPT will then answer your questions and show you the current status of the invoice. –“Can you show me how to create an invoice using natural language commands?” Created by Microsoft Copilot from Microsoft
GPTs
Tangentially, in November 2023 OpenAI announced “custom versions of ChatGPT that you can create for a specific purpose—called GPTs. GPTs are a new way for anyone to create a tailored version of ChatGPT to be more helpful in their daily life, at specific tasks, at work, or at home—and then share that creation with others. For example, GPTs can help you learn the rules of any board game, help teach your kids math, or design stickers.”
The main difference between GPTs and plugins is that GPTs are more customizable and flexible, while plugins are more standardized and reliable. GPTs allow you to create your version of ChatGPT with your instructions and knowledge, while plugins are pre-built by developers and companies to provide specific functionality. GPTs can also use plugins as part of their skills, but not vice versa. GPTs are touted, by some, as the replacement for plugins.
Conclusion
Custom API scripts are generally coded in Python and PHP programming languages. Plugins are off-the-shelf or ready-made API scripts available from various vendors and are accessible from the Plugin Store in the ChatGPT UI. Both API Scripts and plugins advance the use cases of ChatGPT in scope and scale. For example, instead of manual cut-and-paste operations, the accountant can upload complete files of various formats for “processing” via prompting. The accountant can build his/her API script that focuses on accounting or enable specialized accounting plugins from ChatGPT UI such as QuickBooks amongst others. Next time, intending to preserve accountants’ client confidentiality, we look at private database implementation of generative AI.
–Richard Thomas
Previous, Part V
Next, Part VII