cheapgen 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,248 +1,179 @@
1
- # cheapgen
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/jzr-supove/cheapgen/main/docs/images/banner.webp" alt="cheapgen" width="100%">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/cheapgen"><img src="https://img.shields.io/npm/v/cheapgen?label=npm&color=FF7A1A" alt="npm version"></a>
7
+ <a href="https://github.com/jzr-supove/cheapgen/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-FF7A1A" alt="MIT license"></a>
8
+ <img src="https://img.shields.io/badge/node-22%2B-FF7A1A" alt="Node.js 22 or newer">
9
+ <img src="https://img.shields.io/badge/dependencies-0-FF7A1A" alt="No dependencies">
10
+ </p>
2
11
 
3
12
  Several API providers sell the same AI video and image models at different prices. `cheapgen`
4
13
  prices your request on each provider you have a key for and sends it to the cheapest one.
5
14
 
6
- It works with [Kie](https://kie.ai), [Replicate](https://replicate.com),
7
- [WaveSpeed](https://wavespeed.ai) and [fal](https://fal.ai). Coding agents such as Claude Code,
8
- Codex, GitHub Copilot and Cursor can use it too, through a skill, an MCP server or a plugin
9
- ([Use with AI agents](#use-with-ai-agents)).
10
-
11
15
  ```console
12
- $ cheapgen quote seedance-2.0-mini --res 480p --duration 4
13
- seedance-2.0-mini · text-to-video · 480p · 4s · 16:9 · audio on
14
- kie $0.0760 live 2026-11-22 ← run would use this
15
- replicate $0.160 bundled 2026-11-21
16
- wavespeed $0.216 bundled 2026-11-21 (not connected)
17
- fal $0.281 bundled 2026-11-21 (not connected)
16
+ $ cheapgen quote seedance-2.0 --res 720p --duration 5
17
+ seedance-2.0 · text-to-video · 720p · 5s · 16:9 · audio on
18
+ higgsfield $0.867 live 2026-12-05 ← run would use this
19
+ replicate $0.900 bundled 2026-11-21
20
+ kie $1.025 live 2026-12-05
21
+ wavespeed $1.080 live 2026-12-05
22
+ fal $1.512 bundled 2026-11-21
18
23
  ```
19
24
 
20
- > **Early version.** Kie, WaveSpeed and Replicate have been tried with real image, text-to-video and
21
- > image-to-video runs. fal has only been tried for prices, balance and errors; its generation
22
- > requests were built from its docs. The MCP server and the plugins are checked by tests and, for
23
- > Claude Code and Codex, by the apps' own plugin tools, but haven't yet been used in every app.
24
-
25
- ## Install
25
+ The same model and the same request: $0.87 on the cheapest provider that day, $1.51 on the
26
+ dearest.
26
27
 
27
- You need [Node.js](https://nodejs.org) 22 or newer. There are no other dependencies.
28
-
29
- ```sh
30
- npm install -g cheapgen
31
- ```
28
+ It works with [Kie](https://kie.ai), [Replicate](https://replicate.com),
29
+ [WaveSpeed](https://wavespeed.ai), [fal](https://fal.ai) and the
30
+ [Higgsfield](https://higgsfield.ai) API, from the command line or from a coding agent such as
31
+ Claude Code, Codex, GitHub Copilot or Cursor.
32
32
 
33
- ## Add your keys
33
+ > **Early version.** Not every feature has been run for real on every provider yet. See
34
+ > [what has been tried](#what-has-been-tried).
34
35
 
35
- You need a key from at least one provider. This asks for it and hides what you type:
36
+ ## How it works
36
37
 
37
- ```sh
38
- cheapgen config set-key kie
39
- ```
38
+ <p align="center">
39
+ <img src="https://raw.githubusercontent.com/jzr-supove/cheapgen/main/docs/images/routing.svg" alt="Your request is priced on every provider and sent to the cheapest. If that provider refuses it, the next cheapest is tried. If it is unclear whether a job was created, cheapgen stops." width="100%">
40
+ </p>
40
41
 
41
- Use `replicate`, `wavespeed` or `fal` for the others. The key is stored as plain text in
42
- `~/.cheapgen/config.json`, readable only by you on macOS and Linux. Windows can't restrict it the
43
- same way.
42
+ ## Quick start
44
43
 
45
- Environment variables work too, and win over stored keys: `KIE_API_KEY`, `REPLICATE_API_TOKEN`,
46
- `WAVESPEED_API_KEY`, `FAL_KEY`.
44
+ You need [Node.js](https://nodejs.org) 22 or newer. There are no other dependencies.
47
45
 
48
46
  ```sh
49
- cheapgen config list # keys (last 4 characters only) and settings
50
- cheapgen config get-key kie # is this key set, and where does it come from?
51
- cheapgen providers # connected providers and their balances
52
- ```
47
+ npm install -g cheapgen
53
48
 
54
- ## Use
49
+ # Add a key from at least one provider: kie, replicate, wavespeed, fal or higgsfield
50
+ cheapgen config set-key kie
55
51
 
56
- ```sh
57
52
  # What would it cost, and where? Sends nothing to generate.
58
53
  cheapgen quote seedance-2.0-mini --res 480p --duration 4
59
54
 
60
- # See the exact request without sending it.
61
- cheapgen run seedance-2.0-mini --prompt "a paper boat on a pond" --res 480p --duration 4 --dry-run
62
-
63
55
  # Generate, wait, and save the result to ./cheapgen-out
64
56
  cheapgen run seedance-2.0-mini --prompt "a paper boat on a pond" --res 480p --duration 4 --wait
57
+ ```
65
58
 
66
- # An image
67
- cheapgen run seedream-5.5 --prompt "a red bicycle" --size 1K --aspect 1:1 --wait
59
+ `set-key` asks for the key and hides what you type. Environment variables work too. A Higgsfield
60
+ key has two parts. [Providers and keys](https://github.com/jzr-supove/cheapgen/blob/main/docs/providers.md)
61
+ has the details.
68
62
 
69
- # Image to video, from a local file or a URL
70
- cheapgen run seedance-2.0-mini --prompt "the boat drifts away" --image boat.png --wait
63
+ ## What it can do
71
64
 
72
- # Start now, collect later
73
- cheapgen run seedance-2.0-fast --prompt "a lighthouse at night"
74
- cheapgen wait kie:task_123
75
- ```
65
+ Start from `cheapgen run <model> --prompt "..."` and add:
66
+
67
+ | To make | Add | Guide |
68
+ |---|---|---|
69
+ | An image or a video from text | nothing | [Commands](https://github.com/jzr-supove/cheapgen/blob/main/docs/commands.md) |
70
+ | An edited image, or several combined | `--image photo.png`, repeated to combine | [Editing images](https://github.com/jzr-supove/cheapgen/blob/main/docs/image-editing.md) |
71
+ | A video that starts from an image | `--image boat.png` | [Video inputs](https://github.com/jzr-supove/cheapgen/blob/main/docs/video-inputs.md) |
72
+ | A video between two frames | `--image day.png --last-image night.png` | [Video inputs](https://github.com/jzr-supove/cheapgen/blob/main/docs/video-inputs.md) |
73
+ | A video from reference images and audio | `--ref-image hero.png --ref-audio voice.wav` | [Video inputs](https://github.com/jzr-supove/cheapgen/blob/main/docs/video-inputs.md) |
74
+
75
+ <p align="center">
76
+ <img src="https://raw.githubusercontent.com/jzr-supove/cheapgen/main/docs/images/video-inputs.svg" alt="Three ways to steer a video: a first frame, a first and a last frame, or reference images and audio" width="100%">
77
+ </p>
78
+
79
+ - **Local files or URLs.** A local file is uploaded to the provider that runs the job, and to no
80
+ other.
81
+ - **Start now, collect later.** Without `--wait`, `run` prints a job id. `cheapgen wait <job>`
82
+ collects the result.
83
+ - **See before you send.** `--dry-run` shows the exact request and the estimate, and sends
84
+ nothing.
76
85
 
77
86
  `cheapgen --help` lists every option. Add `--json` to any command for scripts.
78
87
 
79
88
  ## Models
80
89
 
81
- | Video | Image |
82
- |---|---|
83
- | `seedance-2.0-mini` | `seedream-5.5` |
84
- | `seedance-2.0-fast` | `seedream-5-pro` |
85
- | `seedance-2.0` | `seedream-5-lite` |
86
- | `seedance-2.5-flash` | `nano-banana-2.1` |
87
- | `seedance-2.5` | `nano-banana-pro` |
88
- | | `flux-2-pro` |
89
-
90
- `cheapgen models` shows each model's resolutions or sizes, and which providers offer it.
91
-
92
- `seedance-2.0` and `seedance-2.5` also come in 4K (`--res 4k`), about $1 to $1.30 a second at the
93
- cheapest provider. The file is 10-bit H.265/HEVC, which some players can't open; VLC and mpv can.
90
+ | Video model | Resolutions | Kie | Replicate | WaveSpeed | fal | Higgsfield |
91
+ |---|---|:-:|:-:|:-:|:-:|:-:|
92
+ | `seedance-2.0-mini` | 480p, 720p | ✓ | ✓ | ✓ | ✓ | |
93
+ | `seedance-2.0-fast` | 480p, 720p | ✓ | ✓ | ✓ | ✓ | |
94
+ | `seedance-2.0` | 480p, 720p, 1080p, 4k | ✓ | ✓ | ✓ | ✓ | ✓ |
95
+ | `seedance-2.5-flash` | 480p, 720p | ✓ | | ✓ | ✓ | |
96
+ | `seedance-2.5` | 480p, 720p, 1080p, 4k | ✓ | ✓ | ✓ | ✓ | ✓ |
97
+
98
+ | Image model | Sizes | Kie | Replicate | WaveSpeed | fal | Higgsfield |
99
+ |---|---|:-:|:-:|:-:|:-:|:-:|
100
+ | `seedream-5.5` | 1K, 1.5K, 2K | ✓ | | ✓ | ✓ | |
101
+ | `seedream-5-pro` | 1K, 2K | ✓ | ✓ | ✓ | ✓ | ✓ |
102
+ | `seedream-5-lite` | 2K, 3K, 4K | ✓ | ✓ | ✓ | ✓ | |
103
+ | `nano-banana-2.1` | 1K, 2K, 4K | ✓ | ✓ | ✓ | ✓ | |
104
+ | `nano-banana-pro` | 1K, 2K, 4K | ✓ | ✓ | ✓ | ✓ | |
105
+ | `flux-2-pro` | 1K, 2K | ✓ | ✓ | ✓ | ✓ | |
106
+
107
+ `cheapgen models` shows the same list, with the providers you have a key for marked.
108
+
109
+ - **4K video** (`--res 4k`) costs about $1 to $1.10 a second at the cheapest provider. The file is
110
+ 10-bit H.265/HEVC, which some players can't open; VLC and mpv can.
111
+ - **Upscaled 1080p and 4K.** WaveSpeed also sells these for the mini, fast and flash models,
112
+ upscaled from 720p. They are off by default; see
113
+ [Configuration](https://github.com/jzr-supove/cheapgen/blob/main/docs/configuration.md#upscaled-resolutions).
94
114
 
95
115
  ## Spending safely
96
116
 
97
- - **Cost limit.** A run that costs more than $1, or whose price is unknown, stops until you confirm
98
- it. Change the limit with `cheapgen config set maxCostPerRun 0.5`, or for one run with
117
+ - **Cost limit.** A run that costs more than $1, or whose price is unknown, stops until you
118
+ confirm it. Change the limit with `cheapgen config set maxCostPerRun 0.5`, or for one run with
99
119
  `--max-cost`. `--yes` starts a run even if it is over the limit.
100
120
  - **No double billing.** If a provider clearly rejects a request, cheapgen tries the next cheapest
101
121
  one. If it can't tell whether the job was created, it stops and says so (exit code 5) instead of
102
122
  risking a second charge.
103
- - **Balances.** Providers whose reported balance can't cover the request are skipped. Replicate has
104
- no balance API.
105
- - **Spend log.** `cheapgen spend` summarizes your runs: the actual charge where the provider reports
106
- it (Kie), $0 for failed Replicate jobs, which Replicate doesn't bill, and otherwise the estimate.
107
- The log stays on your computer and never contains prompts or keys.
108
-
109
- Every price is an estimate and is shown with its source and date. Kie, WaveSpeed and fal prices are
110
- read live when possible; otherwise cheapgen uses the prices bundled in `data/prices.json`. Your
111
- provider's bill is authoritative.
112
-
113
- ## Configuration
114
-
115
- Settings live in `~/.cheapgen/config.json`. A `.cheapgen.json` in the current folder overrides them.
116
-
117
- ```json
118
- {
119
- "strategy": "cheapest",
120
- "prefer": ["kie", "replicate"],
121
- "maxCostPerRun": 1.0,
122
- "providers": { "fal": { "enabled": false } },
123
- "models": { "seedance-2.5": { "provider": "replicate" } }
124
- }
125
- ```
126
-
127
- - `strategy`: `cheapest`, or `preferred` to use the first provider in `prefer` that supports the
128
- request.
129
- - `providers.<id>.enabled`: turn a provider off without removing its key.
130
- - `models.<id>.provider`: always use one provider for a model.
123
+ - **Balances.** Providers whose reported balance can't cover the request are skipped. Replicate and
124
+ Higgsfield have no balance API, so a request they can't cover is only refused when it is sent.
125
+ - **Spend log.** `cheapgen spend` summarizes your runs. The log stays on your computer and never
126
+ contains prompts or keys.
131
127
 
132
- For one run, use `--provider ID` or `--exclude ID`.
128
+ Every price is an estimate and is shown with its source and date. Kie, WaveSpeed, fal and
129
+ Higgsfield prices are read live when possible; otherwise cheapgen uses the prices bundled in
130
+ `data/prices.json`. Your provider's bill is authoritative.
133
131
 
134
- ## Use with AI agents
132
+ ## What has been tried
135
133
 
136
- The package includes a skill that lets a coding agent quote and run generations for you. It
137
- quotes first and asks before spending anything. After installing cheapgen, add the skill:
134
+ Real runs so far, as of 2026-12-05:
138
135
 
139
- ```sh
140
- cheapgen skill install
141
- ```
142
-
143
- This finds the agents on your computer and copies the skill into their folders:
144
-
145
- | Agent | Folder | Install for it alone |
146
- |---|---|---|
147
- | Claude Code | `~/.claude/skills/cheapgen` | `cheapgen skill install --agent claude` |
148
- | Codex, OpenCode, Cursor and other [Agent Skills](https://agentskills.io) agents | `~/.agents/skills/cheapgen` | `cheapgen skill install --agent codex` |
149
- | GitHub Copilot (CLI and VS Code) | `~/.copilot/skills/cheapgen` | `cheapgen skill install --agent copilot` |
150
- | Cursor only | `~/.cursor/skills/cheapgen` | `cheapgen skill install --agent cursor` |
136
+ | | Kie | Replicate | WaveSpeed | fal | Higgsfield |
137
+ |---|:-:|:-:|:-:|:-:|:-:|
138
+ | Image | ✓ | ✓ | ✓ | not yet | ✓ |
139
+ | Image edit | ✓ | ✓ | ✓ | not yet | ✓ |
140
+ | Text-to-video | ✓ | ✓ | ✓ | not yet | not yet |
141
+ | Image-to-video | ✓ | ✓ | ✓ | not yet | not yet |
142
+ | First and last frame | ✓ | ✓ | ✓ | not yet | ✓ |
143
+ | Reference images and audio | ✓ | refused | ✓ | not yet | ✓ |
151
144
 
152
- - `--project` installs into the current folder instead (`.claude/skills`, `.agents/skills`), so
153
- you can commit it with a project. For VS Code, add `--agent copilot`, which uses
154
- `.github/skills`.
155
- - `--agent opencode` is the same as `--agent codex`: OpenCode reads `~/.agents/skills`.
156
- - After `npm update -g cheapgen`, run `cheapgen skill install` again to refresh the copies.
157
- - `cheapgen skill uninstall` removes them. It only ever touches the `cheapgen` skill folder.
158
- - For other agents, `npx skills add jzr-supove/cheapgen` installs the same skill from GitHub.
145
+ fal has been tried for prices, balance and errors; its generation requests were built from its
146
+ docs. On Replicate the reference request was accepted, but the model refused the result.
147
+ [Providers and keys](https://github.com/jzr-supove/cheapgen/blob/main/docs/providers.md#what-has-been-tried-with-real-runs)
148
+ has the full notes.
159
149
 
160
- ### Plugins
150
+ ## Use with AI agents
161
151
 
162
- The plugins bundle the skill and the MCP server below, and start it with
163
- `npx -y cheapgen@latest mcp`, so you don't need to install cheapgen first.
152
+ A coding agent can quote and run generations for you. It quotes first and asks before spending
153
+ anything.
164
154
 
165
155
  ```sh
166
- # Claude Code, inside a session (asks for your keys and keeps them in secure storage)
156
+ # The skill, for the agents on your computer
157
+ cheapgen skill install
158
+
159
+ # Or the plugin for Claude Code, inside a session (no install needed)
167
160
  /plugin marketplace add jzr-supove/cheapgen
168
161
  /plugin install cheapgen@cheapgen
169
-
170
- # Codex
171
- codex plugin marketplace add jzr-supove/cheapgen
172
- codex plugin add cheapgen@cheapgen
173
-
174
- # GitHub Copilot CLI
175
- copilot plugin install jzr-supove/cheapgen
176
-
177
- # Antigravity CLI
178
- agy plugin install https://github.com/jzr-supove/cheapgen
179
-
180
- # Cursor: Customize, then import a plugin from the GitHub repository jzr-supove/cheapgen
181
-
182
- # Gemini CLI, where you still have it
183
- gemini extensions install https://github.com/jzr-supove/cheapgen
184
- ```
185
-
186
- Every key setting is optional. Keys stored with `npx cheapgen config set-key <provider>` work
187
- everywhere. Only Claude Code and Gemini CLI ask for keys, and Codex and Copilot don't pass your
188
- environment variables to plugin servers, so with the others, store your keys that way.
189
-
190
- ### MCP server
191
-
192
- `cheapgen mcp` runs an [MCP](https://modelcontextprotocol.io) server on stdin and stdout, for
193
- apps that use MCP tools rather than skills. With cheapgen installed, add it with the lines below.
194
- Without installing it, use `npx -y cheapgen@latest mcp` as the command instead.
195
-
196
- ```sh
197
- claude mcp add cheapgen -- cheapgen mcp # Claude Code
198
- codex mcp add cheapgen -- cheapgen mcp # Codex
199
- copilot mcp add cheapgen -- cheapgen mcp # GitHub Copilot CLI, also used by VS Code
200
162
  ```
201
163
 
202
- For OpenCode, add it to `~/.config/opencode/opencode.json`:
164
+ There are plugins for Codex, GitHub Copilot, Cursor, Antigravity and Gemini CLI too, and an MCP
165
+ server (`cheapgen mcp`) for apps that use MCP tools.
166
+ [Use with AI agents](https://github.com/jzr-supove/cheapgen/blob/main/docs/agents.md) covers all
167
+ three.
203
168
 
204
- ```json
205
- { "mcp": { "servers": { "cheapgen": { "type": "local", "command": ["cheapgen", "mcp"] } } } }
206
- ```
207
-
208
- For Cursor, this button adds it in one click (it runs `npx -y cheapgen@latest mcp`):
209
-
210
- [![Add cheapgen to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=cheapgen&config=eyJjb21tYW5kIjoibnB4IC15IGNoZWFwZ2VuQGxhdGVzdCBtY3AifQ%3D%3D)
211
-
212
- For Cursor by hand (`~/.cursor/mcp.json`), Claude Desktop and other apps, add this to their MCP
213
- settings:
214
-
215
- ```json
216
- { "mcpServers": { "cheapgen": { "command": "cheapgen", "args": ["mcp"] } } }
217
- ```
169
+ ## Guides
218
170
 
219
- Store your keys with `cheapgen config set-key`, since not every app passes environment variables
220
- on to the servers it starts.
221
-
222
- It has seven tools: `models`, `providers`, `quote`, `run`, `job_status`, `wait_job` and `spend`.
223
-
224
- - **`run` only takes a quote.** The agent calls `quote` first, and `run` starts exactly the
225
- request that was priced. A quote lasts 10 minutes and starts one job. If the price went up
226
- since the quote, `run` stops and asks for a new quote.
227
- - **The cost limit stays yours.** No tool can raise it. Above the limit, apps that support it ask
228
- you directly to confirm the price; the agent can't answer for you. Other apps refuse the run,
229
- and you can raise `maxCostPerRun` or use the CLI.
230
- - `run` returns a job id at once. `wait_job` waits up to two minutes per call and saves the result
231
- to `./cheapgen-out` in the folder the app started the server in. If that is a plugin's own
232
- folder or a drive root, it uses `~/cheapgen-out` instead.
233
-
234
- ## Exit codes
235
-
236
- | Code | Meaning |
237
- |---|---|
238
- | 0 | Done |
239
- | 1 | Unexpected error |
240
- | 2 | Bad arguments or configuration |
241
- | 3 | No provider can take the request |
242
- | 4 | Needs confirmation: over the cost limit, or the price is unknown |
243
- | 5 | Unknown outcome: a job may exist. Check the provider before trying again |
244
- | 6 | The job failed |
245
- | 7 | Timed out waiting; the job may still finish |
171
+ - [Providers and keys](https://github.com/jzr-supove/cheapgen/blob/main/docs/providers.md): keys, prices, balances, what has been tried
172
+ - [Commands](https://github.com/jzr-supove/cheapgen/blob/main/docs/commands.md): every command and option, exit codes
173
+ - [Editing images](https://github.com/jzr-supove/cheapgen/blob/main/docs/image-editing.md): edit one picture or combine several
174
+ - [Video from frames and references](https://github.com/jzr-supove/cheapgen/blob/main/docs/video-inputs.md): first frame, last frame, reference images and audio
175
+ - [Configuration](https://github.com/jzr-supove/cheapgen/blob/main/docs/configuration.md): every setting
176
+ - [Use with AI agents](https://github.com/jzr-supove/cheapgen/blob/main/docs/agents.md): the skill, the plugins and the MCP server
246
177
 
247
178
  ## Development
248
179
 
@@ -254,4 +185,5 @@ Tests make no network calls and spend no credits.
254
185
 
255
186
  ## License
256
187
 
257
- [MIT](LICENSE). cheapgen is not affiliated with Kie, Replicate, WaveSpeed or fal.
188
+ [MIT](https://github.com/jzr-supove/cheapgen/blob/main/LICENSE). cheapgen is not affiliated with
189
+ Kie, Replicate, WaveSpeed, fal or Higgsfield.