ferryai 0.0.0-stage → 0.1.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 +12 -2
- package/bin/ferryai.mjs +212 -0
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ferryai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command line for FerryAI image and video generation.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx -y ferryai image "a red fox in deep snow" --out fox.png
|
|
7
|
+
npx -y ferryai video "drone shot over a fjord" --seconds 4 --wait
|
|
8
|
+
FERRYAI_API_KEY=sk-... npx -y ferryai balance
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Run `npx -y ferryai --help` for every flag. Failures are never charged.
|
|
12
|
+
|
|
13
|
+
Keys: https://ferryai.furrecast.com/keys
|
package/bin/ferryai.mjs
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* FerryAI CLI — generate images and video from the terminal.
|
|
4
|
+
*
|
|
5
|
+
* Auth: FERRYAI_API_KEY (or --key). Keys are created in the console at
|
|
6
|
+
* https://ferryai.furrecast.com/keys and bill your account balance.
|
|
7
|
+
*/
|
|
8
|
+
import { writeFile } from 'node:fs/promises'
|
|
9
|
+
import { basename } from 'node:path'
|
|
10
|
+
|
|
11
|
+
const BASE = (process.env.FERRYAI_BASE_URL || 'https://ferryai.furrecast.com').replace(/\/+$/, '')
|
|
12
|
+
const KEY = process.env.FERRYAI_API_KEY || ''
|
|
13
|
+
|
|
14
|
+
const HELP = `ferryai — image and video generation from the terminal
|
|
15
|
+
|
|
16
|
+
Usage
|
|
17
|
+
ferryai image "<prompt>" [--model nano-banana-2] [--aspect 1:1]
|
|
18
|
+
[--ref <url>]... [--out file] [--dry-run]
|
|
19
|
+
ferryai video "<prompt>" [--model veo-3.1] [--seconds 4|6|8] [--aspect 16:9]
|
|
20
|
+
[--image <url>]... [--wait] [--out file]
|
|
21
|
+
ferryai task <task_id>
|
|
22
|
+
ferryai balance
|
|
23
|
+
ferryai models
|
|
24
|
+
ferryai skill print the agent skill (paste into Claude Code or Codex)
|
|
25
|
+
|
|
26
|
+
Options
|
|
27
|
+
--key <sk-...> API key (default: $FERRYAI_API_KEY)
|
|
28
|
+
--json machine readable output (default for task/balance/models)
|
|
29
|
+
--out <path> download the result to this file
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
ferryai image "a red fox in deep snow" --out fox.png
|
|
33
|
+
ferryai image "same style, night" --ref https://cdn.example/cat.png
|
|
34
|
+
ferryai video "drone shot over a fjord" --seconds 4 --wait --out fjord.mp4
|
|
35
|
+
ferryai balance
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
function parseArgs(argv) {
|
|
39
|
+
const args = { _: [], refs: [], images: [] }
|
|
40
|
+
for (let i = 0; i < argv.length; i++) {
|
|
41
|
+
const arg = argv[i]
|
|
42
|
+
if (arg === '--key') args.key = argv[++i]
|
|
43
|
+
else if (arg === '--model') args.model = argv[++i]
|
|
44
|
+
else if (arg === '--aspect') args.aspect = argv[++i]
|
|
45
|
+
else if (arg === '--seconds') args.seconds = Number(argv[++i])
|
|
46
|
+
else if (arg === '--out') args.out = argv[++i]
|
|
47
|
+
else if (arg === '--ref') args.refs.push(argv[++i])
|
|
48
|
+
else if (arg === '--image') args.images.push(argv[++i])
|
|
49
|
+
else if (arg === '--dry-run') args.dryRun = true
|
|
50
|
+
else if (arg === '--wait') args.wait = true
|
|
51
|
+
else if (arg === '--json') args.json = true
|
|
52
|
+
else if (arg === '--help' || arg === '-h') args.help = true
|
|
53
|
+
else args._.push(arg)
|
|
54
|
+
}
|
|
55
|
+
return args
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function apiKey(args) {
|
|
59
|
+
const key = args.key || KEY
|
|
60
|
+
if (!key) {
|
|
61
|
+
console.error('missing API key: set FERRYAI_API_KEY or pass --key sk-...')
|
|
62
|
+
process.exit(2)
|
|
63
|
+
}
|
|
64
|
+
return key
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function call(args, method, path, body) {
|
|
68
|
+
const response = await fetch(BASE + path, {
|
|
69
|
+
method,
|
|
70
|
+
headers: {
|
|
71
|
+
Authorization: `Bearer ${apiKey(args)}`,
|
|
72
|
+
'Content-Type': 'application/json',
|
|
73
|
+
},
|
|
74
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
75
|
+
})
|
|
76
|
+
const text = await response.text()
|
|
77
|
+
let data
|
|
78
|
+
try {
|
|
79
|
+
data = JSON.parse(text)
|
|
80
|
+
} catch {
|
|
81
|
+
data = { raw: text }
|
|
82
|
+
}
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
const message = data?.error?.message || data?.message || text.slice(0, 200)
|
|
85
|
+
const code = data?.error?.error_code || response.status
|
|
86
|
+
console.error(`error ${code}: ${message}`)
|
|
87
|
+
process.exit(1)
|
|
88
|
+
}
|
|
89
|
+
return data
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function download(url, outPath) {
|
|
93
|
+
const response = await fetch(url)
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
console.error(`download failed: http ${response.status}`)
|
|
96
|
+
process.exit(1)
|
|
97
|
+
}
|
|
98
|
+
const buffer = Buffer.from(await response.arrayBuffer())
|
|
99
|
+
const path = outPath || basename(new URL(url).pathname)
|
|
100
|
+
await writeFile(path, buffer)
|
|
101
|
+
return path
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function print(data, asJson) {
|
|
105
|
+
if (asJson) {
|
|
106
|
+
console.log(JSON.stringify(data, null, 2))
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
if (data.url) {
|
|
110
|
+
console.log(data.url)
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
console.log(JSON.stringify(data, null, 2))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function main() {
|
|
117
|
+
const args = parseArgs(process.argv.slice(2))
|
|
118
|
+
const command = args._[0]
|
|
119
|
+
|
|
120
|
+
if (!command || args.help) {
|
|
121
|
+
console.log(HELP)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (command === 'skill') {
|
|
126
|
+
const response = await fetch(BASE + '/skill.md')
|
|
127
|
+
process.stdout.write(await response.text())
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (command === 'models') {
|
|
132
|
+
const response = await fetch(BASE + '/v1/models')
|
|
133
|
+
print(await response.json(), true)
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (command === 'balance') {
|
|
138
|
+
print(await call(args, 'GET', '/v1/me'), true)
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (command === 'task') {
|
|
143
|
+
const id = args._[1]
|
|
144
|
+
if (!id) {
|
|
145
|
+
console.error('usage: ferryai task <task_id>')
|
|
146
|
+
process.exit(2)
|
|
147
|
+
}
|
|
148
|
+
print(await call(args, 'GET', `/v1/videos/${id}`), true)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (command === 'image') {
|
|
153
|
+
const prompt = args._.slice(1).join(' ')
|
|
154
|
+
if (!prompt) {
|
|
155
|
+
console.error('usage: ferryai image "<prompt>"')
|
|
156
|
+
process.exit(2)
|
|
157
|
+
}
|
|
158
|
+
const body = { model: args.model || 'nano-banana-2', prompt }
|
|
159
|
+
if (args.aspect) body.aspect_ratio = args.aspect
|
|
160
|
+
if (args.refs.length) body.image_input = args.refs
|
|
161
|
+
if (args.dryRun) body.dry_run = true
|
|
162
|
+
const data = await call(args, 'POST', '/v1/images', body)
|
|
163
|
+
if (args.out && data.url) {
|
|
164
|
+
const saved = await download(data.url, args.out)
|
|
165
|
+
console.log(saved)
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
print(data, args.json)
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (command === 'video') {
|
|
173
|
+
const prompt = args._.slice(1).join(' ')
|
|
174
|
+
if (!prompt) {
|
|
175
|
+
console.error('usage: ferryai video "<prompt>"')
|
|
176
|
+
process.exit(2)
|
|
177
|
+
}
|
|
178
|
+
const body = { model: args.model || 'veo-3.1', prompt, seconds: args.seconds || 4 }
|
|
179
|
+
if (args.aspect) body.aspect_ratio = args.aspect
|
|
180
|
+
if (args.images.length) body.image_urls = args.images
|
|
181
|
+
const submitted = await call(args, 'POST', '/v1/videos', body)
|
|
182
|
+
if (!args.wait) {
|
|
183
|
+
print(submitted, true)
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
let task = submitted
|
|
187
|
+
for (let i = 0; i < 120; i++) {
|
|
188
|
+
await new Promise((resolve) => setTimeout(resolve, 5000))
|
|
189
|
+
task = await call(args, 'GET', `/v1/videos/${submitted.task_id}`)
|
|
190
|
+
if (task.status === 'COMPLETED') break
|
|
191
|
+
if (task.status === 'FAILED') {
|
|
192
|
+
console.error(JSON.stringify(task))
|
|
193
|
+
process.exit(1)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (task.url && args.out) {
|
|
197
|
+
console.log(await download(task.url, args.out))
|
|
198
|
+
} else {
|
|
199
|
+
print(task, true)
|
|
200
|
+
}
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
console.error(`unknown command: ${command}\n`)
|
|
205
|
+
console.log(HELP)
|
|
206
|
+
process.exit(2)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
main().catch((error) => {
|
|
210
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
211
|
+
process.exit(1)
|
|
212
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ferryai",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "FerryAI command line: generate images and video from your terminal",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "ferryai": "bin/ferryai.mjs" },
|
|
7
|
+
"engines": { "node": ">=18" },
|
|
8
|
+
"files": ["bin"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": { "type": "git", "url": "git+https://github.com/DevRuibin/ferryai.git" },
|
|
11
|
+
"keywords": ["ferryai", "image-generation", "video-generation", "cli", "nano-banana", "veo"]
|
|
12
|
+
}
|