Create an Invoice Importer Using AI

Recently the code-writing ability of modern LLM tools has improved greatly. There are many problems that tools like OpenAI's ChatGPT or Anthropic's Claude can write code to solve. At the same time, the python ecosystem has become much easier to work with as well. This means it is now possible to write code to integrate your internal systems with tools like MakeLeaps.

To give an example, let's use an LLM to write code that creates invoices in MakeLeaps. We will be using the python programming language and Anthropic's Claude. I will assume you are familiar with basic programming ideas but even if you are not, you should be able to follow along. For this example, we will use Claude as it is quite good at writing python scripts. This approach will also work with OpenAI ChatGPT, Google's Gemini, Deepseek, or any other code-writing LLM.

The Example Problem

We will ask an LLM to write a python script that accepts an Excel or csv spreadsheet with invoice data and create corresponding documents within MakeLeaps. To do this, I will assume a highly simplified spreadsheet, but you can adapt it to whatever data you have.

Info
date,invoice_number,client_name,client_number,total_amount
2025-06-09,00-1234,Client Company KK,CLIENT-5678,¥50,000 JPY

It helps to have headers and some example data for the LLM to use.

Install Python with UV

The first step is to ensure that you can run a simple python script on your local machine. In the past few years installing and running python has become much easier. Just follow the instructions on Astral's uv tool to get python installed. Astral's uv is able to download and install python, create virtual environments, manage dependencies, run scripts and much more. We will depend on uv's ability to quickly install 3rd party tools. Even if you've used python before, we recommend trying it out.

Check their installation instructions or just open a command line terminal and paste in the following:

Bash
curl -LsSf https://astral.sh/uv/install.sh | sh

After installing, you should be able to write a simple python script and have it run locally:

Python
print("Hello world")
Bash
$ uv run example.py
Hello world

Now that you have python installed and running, we can move on to writing the script.

Set up your LLM

As mentioned before, we're going to start with Claude.

The first step is to set up a Claude Project and teach Claude about both uv and MakeLeaps. Create a new project within Claude for creating python scripts.

Anthropic - Create a project screen

Next, click on the project instructions, and add the following prompt:

Info
You write Python tools as single files. They always start with this comment:

# /// script
# requires-python = ">=3.12"
# ///

These files can include dependencies on libraries such as Click. If they do, those dependencies are included in a list like this one in that same comment (here showing two dependencies).

After this, Include a comment with a short 1 line summary of the script followed by a paragraph description of what the script does.

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "click",
#     "sqlite-utils",
# ]
# ///

# An example one-line description of the script
#
# A paragraph about what the script does in 
# more detail goes here...
#

When working with money or numbers intended to be input by users, use the decimal type and avoid using float.
For http requests please use the httpx library.
For CLI tools, use click.

This project prompt lets Claude understand how we want to create and run python scripts in a way that automatically includes dependencies. It will be used by default for any discussions with Claude that take place within the project.

Anthropic Claude screen showing a project-wide system prompt
Teach Claude about the MakeLeaps API

The next step is to help Claude understand how to create and edit MakeLeaps objects. Download the LLM-friendly documentation that MakeLeaps provides and upload them to Claude in the prompt window of the project you set up before.

A screenshot of the Anthropic Claude  Project screen with uploaded MakeLeaps llms.txt files

Now we can give it a try! Add the following prompt and run it. Be sure to change any details about the available columns to match what you have:

Info
Create a Click CLI utility script in python that will read data out of a csv spreadsheet and use that data to create an invoice using the MakeLeaps API. The csv file will have the following columns:

invoice_date, total_amount, total_currency,

The cli should allow passing in a filename to import. It should assume all amounts are in JPY. 

The MakeLeaps API key config file can be loaded like this:

class MakeLeapsConfig(BaseSettings):
	"""Configuration settings for MakeLeaps API."""
	api_base_url: str = "https://api.makeleaps.com"
	client_id: str
	client_secret: str
	partner_mid: str
	request_timeout: int = 30
	
	model_config = SettingsConfigDict(
		env_prefix="MAKELEAPS_",
		env_file=".env",
		env_file_encoding="utf-8",
		case_sensitive=False,
	)

Claude will now create a first-attempt at a script to do what we need. Give it a review and make sure that it makes sense.

To run the script, we will need to create a .env file with the following values that we will get from the MakeLeaps API page:

Info
MAKELEAPS_CLIENT_ID=your_client_id_here
MAKELEAPS_CLIENT_SECRET=your_client_secret_here
MAKELEAPS_PARTNER_MID=your_partner_mid_here

This approach keeps the sensitive MakeLeaps credentials out of the code itself. It also means you can create multiple scripts that use the same credentials.

Set up the API Team Member and keys in MakeLeaps

In MakeLeaps, software tools that we make will access the system as a "client" using a username/password just like your other coworkers do. Start by going to the MakeLeaps API Integrations Page and click the "show details" link. Fill in the Key Name box with something like "Invoice Importer" and "Add API Key" to create a new key.

Also click on the "Edit Rights" button and set up the minimum permissions needed for your script.

While you are here, also copy the MakeLeaps ID (also called a MID in the API docs) and paste it into your .env file.

Run the Script and Iterate

Now you can give the script a try by running it! To do that simply download the script into the same directory as the .env file. When you run the script, it is possible that the LLM has made a mistake in coding... If this is the case, you can try copying and pasting the error into the chat window and it will attempt to correct the mistake.