egaki 0.11.0 → 0.13.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/CHANGELOG.md +66 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +171 -2
- package/dist/cli/clone-generate.d.ts +1 -0
- package/dist/cli/clone-generate.d.ts.map +1 -1
- package/dist/cli/clone-generate.js +1 -1
- package/dist/cli/generate.d.ts +4 -2
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +14 -6
- package/dist/cli/model-catalog.d.ts.map +1 -1
- package/dist/cli/model-catalog.js +158 -5
- package/dist/cli/upscale-generate.d.ts +97 -0
- package/dist/cli/upscale-generate.d.ts.map +1 -0
- package/dist/cli/upscale-generate.js +300 -0
- package/dist/cli/upscale-generate.test.d.ts +2 -0
- package/dist/cli/upscale-generate.test.d.ts.map +1 -0
- package/dist/cli/upscale-generate.test.js +92 -0
- package/dist/cli/voice-change-generate.d.ts +39 -0
- package/dist/cli/voice-change-generate.d.ts.map +1 -0
- package/dist/cli/voice-change-generate.js +123 -0
- package/dist/vite/angled-screen-shader.d.ts +4 -39
- package/dist/vite/angled-screen-shader.d.ts.map +1 -1
- package/dist/vite/angled-screen-shader.js +36 -440
- package/dist/vite/angled-screen.d.ts.map +1 -1
- package/dist/vite/angled-screen.js +9 -7
- package/dist/vite/shader-renderer.d.ts +0 -4
- package/dist/vite/shader-renderer.d.ts.map +1 -1
- package/dist/vite/shader-renderer.js +2 -66
- package/package.json +11 -6
- package/src/cli/cli.ts +231 -2
- package/src/cli/clone-generate.ts +1 -1
- package/src/cli/generate.ts +24 -11
- package/src/cli/model-catalog.ts +167 -5
- package/src/cli/upscale-generate.test.ts +96 -0
- package/src/cli/upscale-generate.ts +395 -0
- package/src/cli/voice-change-generate.ts +187 -0
- package/src/vite/angled-screen-shader.tsx +45 -498
- package/src/vite/angled-screen.tsx +9 -7
- package/src/vite/shader-renderer.tsx +7 -78
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egaki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI image, video, and speech generation CLI with MDX-to-video framework",
|
|
6
6
|
"main": "./dist/cli/main.js",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
"default": "./src/vite/*.tsx"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
"bin":
|
|
51
|
+
"bin": {
|
|
52
|
+
"egaki": "dist/cli/main.js"
|
|
53
|
+
},
|
|
52
54
|
"repository": {
|
|
53
55
|
"type": "git",
|
|
54
56
|
"url": "https://github.com/remorses/egaki.git",
|
|
@@ -85,8 +87,10 @@
|
|
|
85
87
|
"@ai-sdk/google-vertex": "^4.0.137",
|
|
86
88
|
"@ai-sdk/openai": "3.0.36",
|
|
87
89
|
"@ai-sdk/replicate": "2.0.20",
|
|
88
|
-
"@ai-sdk/xai": "^3.0.
|
|
90
|
+
"@ai-sdk/xai": "^3.0.139",
|
|
89
91
|
"@clack/prompts": "^1.0.1",
|
|
92
|
+
"@egaki/angled-screen": "^0.1.0",
|
|
93
|
+
"@egaki/midjourney": "^0.1.0",
|
|
90
94
|
"@fal-ai/client": "^1.10.1",
|
|
91
95
|
"@remotion/media": "4.0.494",
|
|
92
96
|
"@remotion/player": "4.0.494",
|
|
@@ -102,10 +106,11 @@
|
|
|
102
106
|
"mediabunny": "^1.50.8",
|
|
103
107
|
"moveable": "^0.53.0",
|
|
104
108
|
"picocolors": "^1.1.1",
|
|
105
|
-
"react": "19.
|
|
106
|
-
"react-dom": "19.
|
|
109
|
+
"react": "19.3.1",
|
|
110
|
+
"react-dom": "19.3.1",
|
|
107
111
|
"remotion": "4.0.494",
|
|
108
112
|
"safe-mdx": "^1.12.0",
|
|
113
|
+
"sharp": "^0.35.5",
|
|
109
114
|
"shiki": "^4.2.0",
|
|
110
115
|
"spiceflow": "1.26.0-rsc.7",
|
|
111
116
|
"string-dedent": "^3.0.2",
|
|
@@ -113,7 +118,7 @@
|
|
|
113
118
|
"tweakpane": "^4.0.5",
|
|
114
119
|
"vite": "^8.0.10",
|
|
115
120
|
"yaml": "^2.9.0",
|
|
116
|
-
"zod": "^4.
|
|
121
|
+
"zod": "^4.6.7",
|
|
117
122
|
"zustand": "^5.0.14"
|
|
118
123
|
},
|
|
119
124
|
"peerDependencies": {
|
package/src/cli/cli.ts
CHANGED
|
@@ -92,12 +92,21 @@ import {
|
|
|
92
92
|
cloneVoiceUncached as cloneVoice,
|
|
93
93
|
type CloneProvider,
|
|
94
94
|
} from './clone-generate.js'
|
|
95
|
+
import {
|
|
96
|
+
changeVoiceUncached as changeVoice,
|
|
97
|
+
VOICE_CHANGE_PROVIDER_IDS,
|
|
98
|
+
} from './voice-change-generate.js'
|
|
95
99
|
import {
|
|
96
100
|
detectBpm,
|
|
97
101
|
} from './bpm-detect.js'
|
|
98
102
|
import {
|
|
99
103
|
detectLoudness,
|
|
100
104
|
} from './loudness-detect.js'
|
|
105
|
+
import {
|
|
106
|
+
upscaleImageUncached as upscaleImage,
|
|
107
|
+
DEFAULT_UPSCALE_MODEL,
|
|
108
|
+
UPSCALE_MODELS,
|
|
109
|
+
} from './upscale-generate.js'
|
|
101
110
|
|
|
102
111
|
const cli = goke('egaki')
|
|
103
112
|
|
|
@@ -564,6 +573,94 @@ cli
|
|
|
564
573
|
}
|
|
565
574
|
})
|
|
566
575
|
|
|
576
|
+
// ─── upscale command ─────────────────────────────────────────────────────────
|
|
577
|
+
|
|
578
|
+
cli
|
|
579
|
+
.command(
|
|
580
|
+
'upscale <image>',
|
|
581
|
+
dedent`
|
|
582
|
+
Upscale an image: same image, more pixels and finer detail.
|
|
583
|
+
|
|
584
|
+
GPT Image models (default ${DEFAULT_UPSCALE_MODEL}) re-render the input
|
|
585
|
+
at a larger custom size with a strict "keep everything identical" prompt,
|
|
586
|
+
then match its colors to the input. Default size is the largest for the
|
|
587
|
+
aspect ratio: up to 3840px per edge and 8.3 MP. With OPENAI_API_KEY this
|
|
588
|
+
is one call. ChatGPT login returns only about 1.6 MP per call, so the
|
|
589
|
+
image is split into overlapping tiles (up to 16 calls) that are blended.
|
|
590
|
+
|
|
591
|
+
Midjourney (midjourney, midjourney-creative) upscales 2x through your
|
|
592
|
+
logged-in midjourney.com tab in Chrome via the Playwriter extension.
|
|
593
|
+
The input is cover-fit to Midjourney's frame for its aspect ratio, which
|
|
594
|
+
can crop a few pixels from one side.
|
|
595
|
+
|
|
596
|
+
Generative upscalers can change small details. Compare with the original.
|
|
597
|
+
`,
|
|
598
|
+
)
|
|
599
|
+
.option(
|
|
600
|
+
'-m, --model [model]',
|
|
601
|
+
z
|
|
602
|
+
.string()
|
|
603
|
+
.default(DEFAULT_UPSCALE_MODEL)
|
|
604
|
+
.describe(`Upscale model: ${UPSCALE_MODELS.join(', ')}`),
|
|
605
|
+
)
|
|
606
|
+
.option(
|
|
607
|
+
'-o, --output [path]',
|
|
608
|
+
z.string().describe('Output file path. Default: <input>-upscaled.<ext> next to the input'),
|
|
609
|
+
)
|
|
610
|
+
.option(
|
|
611
|
+
'--scale [factor]',
|
|
612
|
+
z.number().describe('Scale factor, e.g. 2. GPT Image default: the largest size the model allows. Midjourney: always 2'),
|
|
613
|
+
)
|
|
614
|
+
.option(
|
|
615
|
+
'--prompt [text]',
|
|
616
|
+
z.string().describe('Extra instructions for GPT Image, or the job prompt for Midjourney (describe the image for midjourney-creative)'),
|
|
617
|
+
)
|
|
618
|
+
.option('--json', 'Output result metadata as JSON to stdout')
|
|
619
|
+
.example('# Upscale with GPT Image to the largest supported size')
|
|
620
|
+
.example('egaki upscale photo.jpg')
|
|
621
|
+
.example('# 2x with GPT Image')
|
|
622
|
+
.example('egaki upscale photo.jpg --scale 2 -o photo-2x.png')
|
|
623
|
+
.example('# Midjourney subtle 2x upscale (needs Chrome + Playwriter, logged into midjourney.com)')
|
|
624
|
+
.example('egaki upscale painting.jpg -m midjourney')
|
|
625
|
+
.example('# Midjourney creative upscale guided by a prompt')
|
|
626
|
+
.example('egaki upscale painting.jpg -m midjourney-creative --prompt "oil painting of cliffs in snow"')
|
|
627
|
+
.action(async (imagePath, options) => {
|
|
628
|
+
const model = options.model ?? DEFAULT_UPSCALE_MODEL
|
|
629
|
+
const image = await readInputSource(imagePath)
|
|
630
|
+
|
|
631
|
+
console.error(pc.dim(`Model: ${model}`))
|
|
632
|
+
console.error(pc.cyan('Upscaling...'))
|
|
633
|
+
|
|
634
|
+
const result = await runProviderCall('Upscale', () => upscaleImage({
|
|
635
|
+
image,
|
|
636
|
+
model,
|
|
637
|
+
scale: options.scale,
|
|
638
|
+
prompt: options.prompt,
|
|
639
|
+
}))
|
|
640
|
+
|
|
641
|
+
const ext = extensionFromMediaType(result.image.mediaType)
|
|
642
|
+
const defaultOutput = isUrl(imagePath)
|
|
643
|
+
? `egaki-upscaled${ext}`
|
|
644
|
+
: path.join(path.dirname(imagePath), `${path.parse(imagePath).name}-upscaled${ext}`)
|
|
645
|
+
const [savedFile] = saveGeneratedFiles([result.image], options.output ?? defaultOutput)
|
|
646
|
+
console.error(pc.dim(`Size: ${result.input.width}x${result.input.height} -> ${result.output.width}x${result.output.height}${result.tiles && result.tiles > 1 ? ` (${result.tiles} tiles)` : ''}`))
|
|
647
|
+
if (result.warning) console.error(pc.yellow(result.warning))
|
|
648
|
+
printCost(result.cost)
|
|
649
|
+
|
|
650
|
+
if (options.json) {
|
|
651
|
+
console.log(JSON.stringify({
|
|
652
|
+
model: result.model,
|
|
653
|
+
file: savedFile,
|
|
654
|
+
input: result.input,
|
|
655
|
+
output: result.output,
|
|
656
|
+
cost: result.cost,
|
|
657
|
+
...(result.tiles ? { tiles: result.tiles } : {}),
|
|
658
|
+
...(result.jobId ? { jobId: result.jobId } : {}),
|
|
659
|
+
...(result.warning ? { warning: result.warning } : {}),
|
|
660
|
+
}, null, 2))
|
|
661
|
+
}
|
|
662
|
+
})
|
|
663
|
+
|
|
567
664
|
// ─── video command ───────────────────────────────────────────────────────────
|
|
568
665
|
|
|
569
666
|
cli
|
|
@@ -635,7 +732,7 @@ cli
|
|
|
635
732
|
z
|
|
636
733
|
.array(z.string())
|
|
637
734
|
.describe(
|
|
638
|
-
'Reference images for R2V generation, repeatable. xAI: 1-7 images. Seedance: 1-9 images (use @Image1 etc. in prompt)',
|
|
735
|
+
'Reference images for R2V generation, repeatable. xAI: 1-7 images (1-14 on grok-imagine-video-1.5). Seedance: 1-9 images (use @Image1 etc. in prompt)',
|
|
639
736
|
),
|
|
640
737
|
)
|
|
641
738
|
.option(
|
|
@@ -1435,6 +1532,134 @@ cli
|
|
|
1435
1532
|
}
|
|
1436
1533
|
})
|
|
1437
1534
|
|
|
1535
|
+
// ─── voice change command ────────────────────────────────────────────────────
|
|
1536
|
+
|
|
1537
|
+
cli
|
|
1538
|
+
.command(
|
|
1539
|
+
'voice change [audio]',
|
|
1540
|
+
dedent`
|
|
1541
|
+
Re-speak an existing recording with another voice (speech-to-speech).
|
|
1542
|
+
Keeps the timing, emotion and delivery of the input; only the voice
|
|
1543
|
+
changes. Supports ElevenLabs (default) and Cartesia.
|
|
1544
|
+
|
|
1545
|
+
The target voice can be any voice ID from the provider's library or a
|
|
1546
|
+
voice made with 'egaki voice clone'. Output is MP3.
|
|
1547
|
+
|
|
1548
|
+
ElevenLabs models: eleven_multilingual_sts_v2 (default),
|
|
1549
|
+
eleven_english_sts_v2. Cartesia has no model option.
|
|
1550
|
+
`,
|
|
1551
|
+
)
|
|
1552
|
+
.option(
|
|
1553
|
+
'--voice [voice]',
|
|
1554
|
+
z
|
|
1555
|
+
.string()
|
|
1556
|
+
.describe('Target voice ID (required). From the provider voice library or egaki voice clone'),
|
|
1557
|
+
)
|
|
1558
|
+
.option(
|
|
1559
|
+
'-p, --provider [provider]',
|
|
1560
|
+
z
|
|
1561
|
+
.enum(VOICE_CHANGE_PROVIDER_IDS)
|
|
1562
|
+
.default('elevenlabs')
|
|
1563
|
+
.describe(`Voice change provider: ${VOICE_CHANGE_PROVIDER_IDS.join(', ')}`),
|
|
1564
|
+
)
|
|
1565
|
+
.option(
|
|
1566
|
+
'-m, --model [model]',
|
|
1567
|
+
z
|
|
1568
|
+
.string()
|
|
1569
|
+
.describe('Provider model ID. ElevenLabs: eleven_multilingual_sts_v2 (default), eleven_english_sts_v2'),
|
|
1570
|
+
)
|
|
1571
|
+
.option(
|
|
1572
|
+
'-o, --output [path]',
|
|
1573
|
+
z
|
|
1574
|
+
.string()
|
|
1575
|
+
.describe('Output file path. Default: <input>-<provider>.mp3 (or egaki-output.mp3 with --stdin)'),
|
|
1576
|
+
)
|
|
1577
|
+
.option(
|
|
1578
|
+
'--remove-background-noise',
|
|
1579
|
+
'ElevenLabs: remove background noise from the input before conversion',
|
|
1580
|
+
)
|
|
1581
|
+
.option(
|
|
1582
|
+
'--stdin',
|
|
1583
|
+
'Read audio from stdin instead of a file path',
|
|
1584
|
+
)
|
|
1585
|
+
.option(
|
|
1586
|
+
'--json',
|
|
1587
|
+
'Output result metadata as JSON to stdout',
|
|
1588
|
+
)
|
|
1589
|
+
.example('# Re-speak a voiceover with an ElevenLabs voice')
|
|
1590
|
+
.example('egaki voice change narration.wav --voice JBFqnCBsd6RMkjVDRZzb -o narration-george.mp3')
|
|
1591
|
+
.example('# Clean a noisy recording while changing the voice')
|
|
1592
|
+
.example('egaki voice change take.m4a --voice <voice-id> --remove-background-noise')
|
|
1593
|
+
.example('# Use Cartesia')
|
|
1594
|
+
.example('egaki voice change take.wav --voice f786b574-daa5-4673-aa0c-cbe3e8534c02 -p cartesia')
|
|
1595
|
+
.example('# Speak your own recording with a cloned voice')
|
|
1596
|
+
.example('egaki voice clone speaker.mp3 --name "Speaker" --provider elevenlabs')
|
|
1597
|
+
.example('egaki voice change my-take.wav --voice <voice-id>')
|
|
1598
|
+
.action(async (audioPath = '', options) => {
|
|
1599
|
+
if (!options.stdin && !audioPath) {
|
|
1600
|
+
console.error(pc.red('No audio provided. Pass an audio file path or use --stdin.'))
|
|
1601
|
+
process.exit(1)
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
const voice = options.voice
|
|
1605
|
+
if (!voice) {
|
|
1606
|
+
console.error(pc.red('Target voice is required. Use --voice <voice-id>.'))
|
|
1607
|
+
process.exit(1)
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
let audioData: Uint8Array
|
|
1611
|
+
let filename: string | undefined
|
|
1612
|
+
|
|
1613
|
+
if (options.stdin) {
|
|
1614
|
+
const chunks: Buffer[] = []
|
|
1615
|
+
for await (const chunk of process.stdin) {
|
|
1616
|
+
chunks.push(chunk)
|
|
1617
|
+
}
|
|
1618
|
+
audioData = new Uint8Array(Buffer.concat(chunks))
|
|
1619
|
+
} else {
|
|
1620
|
+
const resolved = path.resolve(audioPath)
|
|
1621
|
+
if (!fs.existsSync(resolved)) {
|
|
1622
|
+
console.error(pc.red(`File not found: ${resolved}`))
|
|
1623
|
+
process.exit(1)
|
|
1624
|
+
}
|
|
1625
|
+
audioData = new Uint8Array(fs.readFileSync(resolved))
|
|
1626
|
+
filename = path.basename(resolved)
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
const provider = options.provider ?? 'elevenlabs'
|
|
1630
|
+
|
|
1631
|
+
console.error(pc.dim(`Provider: ${provider}`))
|
|
1632
|
+
console.error(pc.dim(`Voice: ${voice}`))
|
|
1633
|
+
console.error(pc.dim(`Audio: ${options.stdin ? 'stdin' : audioPath} (${(audioData.length / 1024).toFixed(1)} KB)`))
|
|
1634
|
+
console.error(pc.cyan('Changing voice...'))
|
|
1635
|
+
|
|
1636
|
+
const result = await runProviderCall('Voice change', () => changeVoice({
|
|
1637
|
+
audio: audioData,
|
|
1638
|
+
voice,
|
|
1639
|
+
provider,
|
|
1640
|
+
model: options.model,
|
|
1641
|
+
filename,
|
|
1642
|
+
removeBackgroundNoise: options.removeBackgroundNoise || false,
|
|
1643
|
+
}))
|
|
1644
|
+
|
|
1645
|
+
const defaultOutput = options.stdin
|
|
1646
|
+
? 'egaki-output'
|
|
1647
|
+
: path.join(path.dirname(audioPath), `${path.parse(audioPath).name}-${provider}`)
|
|
1648
|
+
const finalPath = ensureExtension(options.output ?? defaultOutput, extensionFromMediaType(result.mediaType))
|
|
1649
|
+
fs.writeFileSync(finalPath, result.audio)
|
|
1650
|
+
console.error(pc.green(`Saved: ${finalPath}`))
|
|
1651
|
+
|
|
1652
|
+
if (options.json) {
|
|
1653
|
+
console.log(JSON.stringify({
|
|
1654
|
+
file: finalPath,
|
|
1655
|
+
provider: result.provider,
|
|
1656
|
+
model: result.model,
|
|
1657
|
+
voice,
|
|
1658
|
+
bytes: result.audio.length,
|
|
1659
|
+
}, null, 2))
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
|
|
1438
1663
|
// ─── models command ──────────────────────────────────────────────────────────
|
|
1439
1664
|
|
|
1440
1665
|
cli
|
|
@@ -1714,6 +1939,10 @@ const FEATURED_IMAGE_MODELS = [
|
|
|
1714
1939
|
'gemini-2.5-flash-image',
|
|
1715
1940
|
'gemini-3.1-flash-image-preview',
|
|
1716
1941
|
'nano-banana-pro-preview',
|
|
1942
|
+
'gpt-image-2.6-sunburst',
|
|
1943
|
+
'gpt-image-2.6-flare',
|
|
1944
|
+
'gpt-image-2.5-sunburst',
|
|
1945
|
+
'gpt-image-2.5-flare',
|
|
1717
1946
|
'gpt-image-2',
|
|
1718
1947
|
'gpt-image-1.5',
|
|
1719
1948
|
'chatgpt-image-latest',
|
|
@@ -1722,7 +1951,7 @@ const FEATURED_IMAGE_MODELS = [
|
|
|
1722
1951
|
'flux-pro-1.1-ultra',
|
|
1723
1952
|
'recraft-v4',
|
|
1724
1953
|
'dall-e-3',
|
|
1725
|
-
'grok-imagine-image-
|
|
1954
|
+
'grok-imagine-image-2.0',
|
|
1726
1955
|
]
|
|
1727
1956
|
|
|
1728
1957
|
/**
|
|
@@ -67,7 +67,7 @@ function validateOptions(opts: CloneVoiceOptions): Error | void {
|
|
|
67
67
|
|
|
68
68
|
// ─── MIME type helper ───────────────────────────────────────────────────────
|
|
69
69
|
|
|
70
|
-
function mimeTypeFromFilename(filename?: string): string {
|
|
70
|
+
export function mimeTypeFromFilename(filename?: string): string {
|
|
71
71
|
if (!filename) return 'audio/mpeg'
|
|
72
72
|
const ext = filename.split('.').pop()?.toLowerCase()
|
|
73
73
|
const map: Record<string, string> = {
|
package/src/cli/generate.ts
CHANGED
|
@@ -64,15 +64,15 @@ export type ImageModelId =
|
|
|
64
64
|
| 'flux-2-pro' | 'flux-2-max' | 'flux-2-flex' | 'flux-2-klein-9b' | 'flux-2-klein-4b'
|
|
65
65
|
| 'recraft-v2' | 'recraft-v3' | 'recraft-v4' | 'recraft-v4-pro' | 'recraft-v4.1' | 'recraft-v4.1-pro' | 'recraft-v4.1-utility' | 'recraft-v4.1-utility-pro'
|
|
66
66
|
| 'seedream-5.0-lite' | 'seedream-4.5' | 'seedream-4.0'
|
|
67
|
-
| 'grok-imagine-image' | 'grok-imagine-image-quality'
|
|
68
|
-
| 'dall-e-2' | 'dall-e-3' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest'
|
|
67
|
+
| 'grok-imagine-image' | 'grok-imagine-image-2.0' | 'grok-imagine-image-quality'
|
|
68
|
+
| 'dall-e-2' | 'dall-e-3' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'chatgpt-image-latest'
|
|
69
69
|
| (string & {})
|
|
70
70
|
|
|
71
71
|
/** Video model IDs from the catalog. Accepts arbitrary strings too. */
|
|
72
72
|
export type VideoModelId =
|
|
73
73
|
| 'veo-3.1-generate-001' | 'veo-3.1-fast-generate-001' | 'veo-3.0-generate-001' | 'veo-3.0-fast-generate-001'
|
|
74
74
|
| 'vertex/veo-3.1-generate-001' | 'vertex/veo-3.1-fast-generate-001'
|
|
75
|
-
| 'grok-imagine-video' | 'grok-imagine-video-1.5'
|
|
75
|
+
| 'grok-imagine-video' | 'grok-imagine-video-1.5' | 'grok-imagine-video-1.5-lite'
|
|
76
76
|
| 'kling-v3.0-t2v' | 'kling-v3.0-i2v' | 'kling-v3.0-motion-control' | 'kling-v2.6-t2v' | 'kling-v2.6-i2v' | 'kling-v2.6-motion-control'
|
|
77
77
|
| 'kling-v2.5-turbo-t2v' | 'kling-v2.5-turbo-i2v'
|
|
78
78
|
| 'wan-v2.6-t2v' | 'wan-v2.6-i2v' | 'wan-v2.6-i2v-flash' | 'wan-v2.6-r2v' | 'wan-v2.6-r2v-flash' | 'wan-v2.5-t2v-preview'
|
|
@@ -114,6 +114,8 @@ export interface GenerateImageOptions {
|
|
|
114
114
|
negativePrompt?: string
|
|
115
115
|
/** Only for text-model image generation (Gemini). */
|
|
116
116
|
imageSize?: '1K' | '2K' | '4K'
|
|
117
|
+
/** Exact output size for models with a `size` parameter (OpenAI). Overrides the aspect ratio fallback. */
|
|
118
|
+
size?: `${number}x${number}`
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
export interface GenerateImageResult {
|
|
@@ -159,7 +161,7 @@ export interface GenerateVideoResult {
|
|
|
159
161
|
// ─── OpenAI provider options type (not exported by @ai-sdk/openai) ───────────
|
|
160
162
|
|
|
161
163
|
type OpenAIImageProviderOptions = {
|
|
162
|
-
quality?: 'standard' | 'low' | 'medium' | 'high' | 'auto'
|
|
164
|
+
quality?: 'standard' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto'
|
|
163
165
|
outputFormat?: 'png' | 'jpeg' | 'webp'
|
|
164
166
|
outputCompression?: number
|
|
165
167
|
size?: `${number}x${number}`
|
|
@@ -199,7 +201,8 @@ export function buildImageProviderOptions(
|
|
|
199
201
|
}
|
|
200
202
|
case 'xai': {
|
|
201
203
|
const xaiOpts = {
|
|
202
|
-
|
|
204
|
+
// 'auto' is xAI's server default; @ai-sdk/xai does not accept it, so omit the field.
|
|
205
|
+
...(opts.quality && opts.quality !== 'auto' ? { quality: opts.quality as XaiImageModelOptions['quality'] } : {}),
|
|
203
206
|
...(opts.resolution ? { resolution: opts.resolution as XaiImageModelOptions['resolution'] } : {}),
|
|
204
207
|
...(opts.outputFormat ? { output_format: opts.outputFormat } : {}),
|
|
205
208
|
} satisfies XaiImageModelOptions
|
|
@@ -238,7 +241,7 @@ export function buildVideoProviderOptions(
|
|
|
238
241
|
switch (provider) {
|
|
239
242
|
case 'xai': {
|
|
240
243
|
const base = {
|
|
241
|
-
...(opts.resolution ? { resolution: opts.resolution as '480p' | '720p' } : {}),
|
|
244
|
+
...(opts.resolution ? { resolution: opts.resolution as '480p' | '720p' | '1080p' } : {}),
|
|
242
245
|
}
|
|
243
246
|
if (opts.mode === 'edit-video' && opts.videoUrl) {
|
|
244
247
|
const xaiOpts = { ...base, mode: 'edit-video' as const, videoUrl: opts.videoUrl } satisfies XaiVideoModelOptions
|
|
@@ -495,6 +498,8 @@ export async function generateImageUncached(opts: GenerateImageOptions): Promise
|
|
|
495
498
|
seed: opts.seed,
|
|
496
499
|
maskImage: opts.maskImage,
|
|
497
500
|
inputImages,
|
|
501
|
+
quality: opts.quality,
|
|
502
|
+
size: opts.size,
|
|
498
503
|
})
|
|
499
504
|
}
|
|
500
505
|
|
|
@@ -512,6 +517,7 @@ export async function generateImageUncached(opts: GenerateImageOptions): Promise
|
|
|
512
517
|
resolution: opts.resolution,
|
|
513
518
|
outputFormat: opts.outputFormat,
|
|
514
519
|
negativePrompt: opts.negativePrompt,
|
|
520
|
+
size: opts.size,
|
|
515
521
|
})
|
|
516
522
|
}
|
|
517
523
|
|
|
@@ -626,6 +632,7 @@ async function generateWithImageModel(opts: {
|
|
|
626
632
|
resolution?: string
|
|
627
633
|
outputFormat?: string
|
|
628
634
|
negativePrompt?: string
|
|
635
|
+
size?: `${number}x${number}`
|
|
629
636
|
}): Promise<Error | GenerateImageResult> {
|
|
630
637
|
const config = getModelConfig(opts.model)
|
|
631
638
|
if (config instanceof Error) return config
|
|
@@ -634,9 +641,11 @@ async function generateWithImageModel(opts: {
|
|
|
634
641
|
// parameter, so the request is expressed through `size` + the prompt text.
|
|
635
642
|
const features = config.strategy === 'video' ? undefined : config.features
|
|
636
643
|
const supportsNativeAspectRatio = (features?.aspectRatios?.length ?? 0) > 0
|
|
637
|
-
const fallback =
|
|
638
|
-
? { prompt: opts.prompt, size:
|
|
639
|
-
:
|
|
644
|
+
const fallback = opts.size
|
|
645
|
+
? { prompt: opts.prompt, size: opts.size }
|
|
646
|
+
: supportsNativeAspectRatio
|
|
647
|
+
? { prompt: opts.prompt, size: undefined }
|
|
648
|
+
: aspectRatioFallback(opts.prompt, opts.aspectRatio, features?.sizes ?? [])
|
|
640
649
|
|
|
641
650
|
const imagePrompt = opts.inputImages.length > 0
|
|
642
651
|
? { text: fallback.prompt, images: opts.inputImages, ...(opts.maskImage ? { mask: opts.maskImage } : {}) }
|
|
@@ -770,6 +779,8 @@ async function generateWithResponsesApi(opts: {
|
|
|
770
779
|
seed?: number
|
|
771
780
|
maskImage?: Uint8Array
|
|
772
781
|
inputImages: Uint8Array[]
|
|
782
|
+
quality?: string
|
|
783
|
+
size?: `${number}x${number}`
|
|
773
784
|
}): Promise<Error | GenerateImageResult> {
|
|
774
785
|
if (opts.count !== 1) {
|
|
775
786
|
return new ValidationError('ChatGPT image generation currently supports exactly one output image.')
|
|
@@ -783,7 +794,9 @@ async function generateWithResponsesApi(opts: {
|
|
|
783
794
|
return new ValidationError('ChatGPT image generation does not support mask yet.')
|
|
784
795
|
}
|
|
785
796
|
|
|
786
|
-
const { prompt, size } =
|
|
797
|
+
const { prompt, size } = opts.size
|
|
798
|
+
? { prompt: opts.prompt, size: opts.size }
|
|
799
|
+
: aspectRatioFallback(opts.prompt, opts.aspectRatio, OPENAI_SIZES)
|
|
787
800
|
|
|
788
801
|
const storedAuth = getChatGptAuth()
|
|
789
802
|
if (!storedAuth?.accountId) {
|
|
@@ -818,7 +831,7 @@ async function generateWithResponsesApi(opts: {
|
|
|
818
831
|
{
|
|
819
832
|
type: 'image_generation',
|
|
820
833
|
model: opts.model,
|
|
821
|
-
quality: 'auto',
|
|
834
|
+
quality: opts.quality ?? 'auto',
|
|
822
835
|
output_format: 'png',
|
|
823
836
|
output_compression: 100,
|
|
824
837
|
moderation: 'auto',
|