CLI: create from the terminal
A CLI is a command line tool: you type a command in the terminal instead of writing code. Ours is one file, lowcost.mjs, with no dependencies, that runs on Node 18 or newer. It checks the price, generates, waits and downloads in one command, and it uses exactly the API documented here.
On this page
Install
You need Node.js 18 or newer. Download the file and run it with node:
curl -o lowcost.mjs https://low-cost.ai/lowcost.mjs node lowcost.mjs help
You can also download it directly from lowcost.mjs. In Windows PowerShell write curl.exe instead of curl. Every example here starts with node lowcost.mjs, run from the folder where you saved the file.
Sign in with a key
Create a key on the developers page and save it once:
node lowcost.mjs login $LCA_KEY
The output:
saved to /home/you/.lowcostai/config.json
- The command only checks that the key starts with lca_. It does not contact the server, so a wrong key shows up only on the next command
- The key and address are saved in ~/.lowcostai/config.json, in your home folder, readable by the owner only
- The LOWCOSTAI_KEY and LOWCOSTAI_URL environment variables win over the file. That lets you run without login, on a server or in a script for example
- The default address is https://low-cost.ai. The --url flag changes it, and the CLI refuses any address that is not https, except http to the local machine
- models, describe and estimate work without a key. gen and upload require one, and the other commands get 401 without it
How flags work
Every model option is a flag named after the parameter. What you see in describe is exactly what you can send:
- --key value or --key=value
- A flag repeated several times is sent as a list. That is how you send several images in images
- A flag with no value, or followed by another flag, is sent as true
- Words without a flag after the model name are joined into one text and sent as prompt, or as text on a speech model that has no prompt
- All values are sent as text, and the server converts numbers and booleans
- Four flags belong to the CLI and are not sent to the model: --max, --wait, --out, --json
node lowcost.mjs gen nano-banana-pro "a coffee cup on a wooden table" --images https://example.com/a.png --images https://example.com/b.png --aspect_ratio 4:5
Every command
| Command | What it does | Key |
|---|---|---|
| login <api-key> [--url URL] | Saves the key and address | No |
| models [video|image|audio|analysis] | Models and their price at default settings | No |
| describe <model> | Every parameter of a model, as a flag | No |
| estimate <model> ["prompt"] [--opt value]... | The exact price, with no charge | No |
| gen <model> "prompt" [--opt value]... [--max CREDITS] [--wait] [--out DIR] [--json] | Generate | Yes |
| status <job> [--wait] [--json] | Job status and links | Yes |
| upload <file> | Upload an input file and print its link | Yes |
| jobs | The 20 most recent jobs | Yes |
| files | The 50 most recent files and storage | Yes |
| balance | Balance and storage | Yes |
| download <file-url> [--out DIR] | Download a file from a link | Depends on the link |
| help | Help | No |
In the sample output, values in angle brackets such as <price> are what you will see on your side.
models
Prints every model: id, category, price at default settings and name. You can filter to one category. Calls GET /api/v1/models.
node lowcost.mjs models video
kling-3.0 video <price> credits at default settings Kling 3.0
describe
Prints every parameter of a model as a flag, with its type, allowed values or range, default, whether it is required and its label. Calls GET /api/v1/models/{id}.
node lowcost.mjs describe kling-3.0
Kling 3.0 (kling-3.0) video <price> credits at default settings --prompt text [up to 2500 characters] (required) <label> --duration enum [3|4|5|6|7|8|9|10|11|12|13|14|15] default 5 <label> --aspect_ratio enum [16:9|9:16|1:1] default 16:9 <label>
estimate
Returns the exact price with no charge. Calls GET /api/v1/models/{id} and POST /api/v1/estimate.
node lowcost.mjs estimate kling-3.0 "Tel Aviv street after rain" --duration 5 --aspect_ratio 9:16
<price> credits
gen
Generates. Without --max, the CLI makes an estimate just before and sends it as max_credits. Without --wait or --out it prints the job and exits at once.
- --max CREDITS: the price cap. If the price is higher, the generation is refused with no charge
- --wait: waits for the end, checking every 3 seconds with no time limit, and prints dots while waiting
- --out DIR: waits and downloads each file to the folder. No need for --wait as well
- --json: for an analysis job, prints the report as raw JSON
node lowcost.mjs gen kling-3.0 "Tel Aviv street after rain" --duration 5 --aspect_ratio 9:16 --max 12.5 --out ./clips
job 6f1c2e0a-1b2c-4d5e-8f90-123456789abc <price> credits queued .... succeeded clips/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90.mp4
Without --out the link to each file is printed instead of the path. A failed job prints failed (credits refunded).
status
A job's status, price and file links. With --wait it waits for the end. An analysis job also prints its report. Calls GET /api/v1/jobs/{id}.
node lowcost.mjs status 6f1c2e0a-1b2c-4d5e-8f90-123456789abc --wait
6f1c2e0a-1b2c-4d5e-8f90-123456789abc kling-3.0 succeeded <price> credits https://low-cost.ai/f/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90?t=<signature>&e=<day>
upload
Uploads a file to your library and prints a link you pass to a model as a parameter. The type comes from the extension: png, jpg, webp, gif, mp4, webm, mov, mp3, wav, ogg, m4a, flac. Up to 4 MB. Calls POST /api/v1/files.
node lowcost.mjs upload ./frame.png
https://low-cost.ai/f/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90?t=<signature>&e=<day>
Then, for example:
node lowcost.mjs gen kling-3.0 "slow push in" --image "https://low-cost.ai/f/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90?t=<signature>&e=<day>" --wait
jobs files and balance
node lowcost.mjs jobs node lowcost.mjs files node lowcost.mjs balance
- jobs prints the 20 most recent jobs: time, status, price, model and id. Calls GET /api/v1/jobs?limit=20
- files prints the 50 most recent files: time, type, size in MB and link, and at the end how many GB are stored of the free GB. Calls GET /api/v1/files?limit=50
- balance prints the balance in credits and the stored size. Calls GET /api/v1/me
<credits> credits (0.00 GB stored)
download
Downloads a file from a link into a folder, the current one by default. The file name is the file id, and the extension follows the file type. The key is sent only if the link is on the service address, never to another site.
node lowcost.mjs download "https://low-cost.ai/f/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90?t=<signature>&e=<day>" --out ./clips
clips/0b6d4f2e-7a1c-4e3b-9d8f-2c5a6b7e8f90.mp4
Errors and exit codes
Every API error answer is printed to stderr as error <status>: <json>, and the CLI exits with code 1. The codes themselves are explained on the errors page. Messages the CLI prints on its own:
| Message | What to do |
|---|---|
| run: lowcost login <api-key> | gen or upload with no key. Run login |
| usage: lowcost login lca_... [--url https://your-domain] | The key you gave does not start with lca_ |
| missing model or job id; run: lowcost help | A model name or job id is missing |
| not a URL: ... | The address in --url or LOWCOSTAI_URL is invalid |
| refusing ...: use https (plain http only for localhost) | The address is not https |
| usage: lowcost upload <file> | A file name is missing |
| unsupported file type: .xyz | An extension that is not on the list |
| max 4 MB: export the clip at 720p | The file is larger than 4 MB |
| download <status> | The link did not open. Get a fresh link with status |
What the CLI does not do
Credit history, deleting files, managing keys, updating account details, estimates with variants, paging past 20 jobs and 50 files, and a time limit on --wait. Do all of these through the API or on the website.