varg.ai-sdk 0.1.0 → 0.4.0-alpha.1

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.
Files changed (236) hide show
  1. package/.claude/settings.local.json +1 -1
  2. package/.env.example +3 -0
  3. package/.github/workflows/ci.yml +23 -0
  4. package/.husky/README.md +102 -0
  5. package/.husky/commit-msg +6 -0
  6. package/.husky/pre-commit +9 -0
  7. package/.husky/pre-push +6 -0
  8. package/.size-limit.json +8 -0
  9. package/.test-hooks.ts +5 -0
  10. package/CLAUDE.md +10 -3
  11. package/CONTRIBUTING.md +150 -0
  12. package/LICENSE.md +53 -0
  13. package/README.md +56 -209
  14. package/SKILLS.md +26 -10
  15. package/biome.json +7 -1
  16. package/bun.lock +1286 -0
  17. package/commitlint.config.js +22 -0
  18. package/docs/index.html +1130 -0
  19. package/docs/prompting.md +326 -0
  20. package/docs/react.md +834 -0
  21. package/docs/sdk.md +812 -0
  22. package/ffmpeg/CLAUDE.md +68 -0
  23. package/package.json +48 -8
  24. package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
  25. package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
  26. package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
  27. package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
  28. package/pipeline/cookbooks/text-to-tiktok.md +669 -0
  29. package/pipeline/cookbooks/trendwatching.md +156 -0
  30. package/plan.md +281 -0
  31. package/scripts/.gitkeep +0 -0
  32. package/src/ai-sdk/cache.ts +142 -0
  33. package/src/ai-sdk/examples/cached-generation.ts +53 -0
  34. package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
  35. package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
  36. package/src/ai-sdk/examples/duet-video.ts +56 -0
  37. package/src/ai-sdk/examples/editly-composition.ts +63 -0
  38. package/src/ai-sdk/examples/editly-test.ts +57 -0
  39. package/src/ai-sdk/examples/editly-video-test.ts +52 -0
  40. package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
  41. package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
  42. package/src/ai-sdk/examples/music-generation.ts +19 -0
  43. package/src/ai-sdk/examples/openai-sora.ts +34 -0
  44. package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
  45. package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
  46. package/src/ai-sdk/examples/talking-lion.ts +55 -0
  47. package/src/ai-sdk/examples/video-generation.ts +39 -0
  48. package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
  49. package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
  50. package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
  51. package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
  52. package/src/ai-sdk/file-cache.ts +112 -0
  53. package/src/ai-sdk/file.ts +238 -0
  54. package/src/ai-sdk/generate-element.ts +92 -0
  55. package/src/ai-sdk/generate-music.ts +46 -0
  56. package/src/ai-sdk/generate-video.ts +165 -0
  57. package/src/ai-sdk/index.ts +72 -0
  58. package/src/ai-sdk/music-model.ts +110 -0
  59. package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
  60. package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
  61. package/src/ai-sdk/providers/editly/index.ts +817 -0
  62. package/src/ai-sdk/providers/editly/layers.ts +776 -0
  63. package/src/ai-sdk/providers/editly/plan.md +144 -0
  64. package/src/ai-sdk/providers/editly/types.ts +328 -0
  65. package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
  66. package/src/ai-sdk/providers/fal-provider.ts +512 -0
  67. package/src/ai-sdk/providers/higgsfield.ts +379 -0
  68. package/src/ai-sdk/providers/openai.ts +251 -0
  69. package/src/ai-sdk/providers/replicate.ts +16 -0
  70. package/src/ai-sdk/video-model.ts +185 -0
  71. package/src/cli/commands/find.tsx +137 -0
  72. package/src/cli/commands/help.tsx +85 -0
  73. package/src/cli/commands/index.ts +6 -0
  74. package/src/cli/commands/list.tsx +238 -0
  75. package/src/cli/commands/render.tsx +71 -0
  76. package/src/cli/commands/run.tsx +511 -0
  77. package/src/cli/commands/which.tsx +253 -0
  78. package/src/cli/index.ts +114 -0
  79. package/src/cli/quiet.ts +44 -0
  80. package/src/cli/types.ts +32 -0
  81. package/src/cli/ui/components/Badge.tsx +29 -0
  82. package/src/cli/ui/components/DataTable.tsx +51 -0
  83. package/src/cli/ui/components/Header.tsx +23 -0
  84. package/src/cli/ui/components/HelpBlock.tsx +44 -0
  85. package/src/cli/ui/components/KeyValue.tsx +33 -0
  86. package/src/cli/ui/components/OptionRow.tsx +81 -0
  87. package/src/cli/ui/components/Separator.tsx +23 -0
  88. package/src/cli/ui/components/StatusBox.tsx +108 -0
  89. package/src/cli/ui/components/VargBox.tsx +51 -0
  90. package/src/cli/ui/components/VargProgress.tsx +36 -0
  91. package/src/cli/ui/components/VargSpinner.tsx +34 -0
  92. package/src/cli/ui/components/VargText.tsx +56 -0
  93. package/src/cli/ui/components/index.ts +19 -0
  94. package/src/cli/ui/index.ts +12 -0
  95. package/src/cli/ui/render.ts +35 -0
  96. package/src/cli/ui/theme.ts +63 -0
  97. package/src/cli/utils.ts +78 -0
  98. package/src/core/executor/executor.ts +201 -0
  99. package/src/core/executor/index.ts +13 -0
  100. package/src/core/executor/job.ts +214 -0
  101. package/src/core/executor/pipeline.ts +222 -0
  102. package/src/core/index.ts +11 -0
  103. package/src/core/registry/index.ts +9 -0
  104. package/src/core/registry/loader.ts +149 -0
  105. package/src/core/registry/registry.ts +221 -0
  106. package/src/core/registry/resolver.ts +206 -0
  107. package/src/core/schema/helpers.ts +134 -0
  108. package/src/core/schema/index.ts +8 -0
  109. package/src/core/schema/shared.ts +102 -0
  110. package/src/core/schema/types.ts +279 -0
  111. package/src/core/schema/validator.ts +92 -0
  112. package/src/definitions/actions/captions.ts +261 -0
  113. package/src/definitions/actions/edit.ts +298 -0
  114. package/src/definitions/actions/image.ts +125 -0
  115. package/src/definitions/actions/index.ts +114 -0
  116. package/src/definitions/actions/music.ts +205 -0
  117. package/src/definitions/actions/sync.ts +128 -0
  118. package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +63 -90
  119. package/src/definitions/actions/upload.ts +111 -0
  120. package/src/definitions/actions/video.ts +163 -0
  121. package/src/definitions/actions/voice.ts +119 -0
  122. package/src/definitions/index.ts +23 -0
  123. package/src/definitions/models/elevenlabs.ts +50 -0
  124. package/src/definitions/models/flux.ts +56 -0
  125. package/src/definitions/models/index.ts +36 -0
  126. package/src/definitions/models/kling.ts +56 -0
  127. package/src/definitions/models/llama.ts +54 -0
  128. package/src/definitions/models/nano-banana-pro.ts +102 -0
  129. package/src/definitions/models/sonauto.ts +68 -0
  130. package/src/definitions/models/soul.ts +65 -0
  131. package/src/definitions/models/wan.ts +54 -0
  132. package/src/definitions/models/whisper.ts +44 -0
  133. package/src/definitions/skills/index.ts +12 -0
  134. package/src/definitions/skills/talking-character.ts +87 -0
  135. package/src/definitions/skills/text-to-tiktok.ts +97 -0
  136. package/src/index.ts +118 -0
  137. package/src/providers/apify.ts +269 -0
  138. package/src/providers/base.ts +264 -0
  139. package/src/providers/elevenlabs.ts +217 -0
  140. package/src/providers/fal.ts +392 -0
  141. package/src/providers/ffmpeg.ts +544 -0
  142. package/src/providers/fireworks.ts +193 -0
  143. package/src/providers/groq.ts +149 -0
  144. package/src/providers/higgsfield.ts +145 -0
  145. package/src/providers/index.ts +143 -0
  146. package/src/providers/replicate.ts +147 -0
  147. package/src/providers/storage.ts +206 -0
  148. package/src/react/cli.ts +52 -0
  149. package/src/react/elements.ts +146 -0
  150. package/src/react/examples/branching.tsx +66 -0
  151. package/src/react/examples/captions-demo.tsx +37 -0
  152. package/src/react/examples/character-video.tsx +84 -0
  153. package/src/react/examples/grid.tsx +53 -0
  154. package/src/react/examples/layouts-demo.tsx +57 -0
  155. package/src/react/examples/madi.tsx +60 -0
  156. package/src/react/examples/music-test.tsx +35 -0
  157. package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
  158. package/src/react/examples/orange-portrait.tsx +41 -0
  159. package/src/react/examples/split-element-demo.tsx +60 -0
  160. package/src/react/examples/split-layout-demo.tsx +60 -0
  161. package/src/react/examples/split.tsx +41 -0
  162. package/src/react/examples/video-grid.tsx +46 -0
  163. package/src/react/index.ts +43 -0
  164. package/src/react/layouts/grid.tsx +28 -0
  165. package/src/react/layouts/index.ts +2 -0
  166. package/src/react/layouts/split.tsx +20 -0
  167. package/src/react/react.test.ts +309 -0
  168. package/src/react/render.ts +21 -0
  169. package/src/react/renderers/animate.ts +59 -0
  170. package/src/react/renderers/captions.ts +297 -0
  171. package/src/react/renderers/clip.ts +248 -0
  172. package/src/react/renderers/context.ts +17 -0
  173. package/src/react/renderers/image.ts +109 -0
  174. package/src/react/renderers/index.ts +22 -0
  175. package/src/react/renderers/music.ts +60 -0
  176. package/src/react/renderers/packshot.ts +84 -0
  177. package/src/react/renderers/progress.ts +173 -0
  178. package/src/react/renderers/render.ts +243 -0
  179. package/src/react/renderers/slider.ts +69 -0
  180. package/src/react/renderers/speech.ts +53 -0
  181. package/src/react/renderers/split.ts +91 -0
  182. package/src/react/renderers/subtitle.ts +16 -0
  183. package/src/react/renderers/swipe.ts +75 -0
  184. package/src/react/renderers/title.ts +17 -0
  185. package/src/react/renderers/utils.ts +124 -0
  186. package/src/react/renderers/video.ts +127 -0
  187. package/src/react/runtime/jsx-dev-runtime.ts +43 -0
  188. package/src/react/runtime/jsx-runtime.ts +35 -0
  189. package/src/react/types.ts +232 -0
  190. package/src/studio/index.ts +26 -0
  191. package/src/studio/scanner.ts +102 -0
  192. package/src/studio/server.ts +554 -0
  193. package/src/studio/stages.ts +251 -0
  194. package/src/studio/step-renderer.ts +279 -0
  195. package/src/studio/types.ts +60 -0
  196. package/src/studio/ui/cache.html +303 -0
  197. package/src/studio/ui/index.html +1820 -0
  198. package/src/tests/all.test.ts +509 -0
  199. package/src/tests/index.ts +33 -0
  200. package/src/tests/unit.test.ts +403 -0
  201. package/tsconfig.cli.json +8 -0
  202. package/tsconfig.json +21 -3
  203. package/TEST_RESULTS.md +0 -122
  204. package/action/captions/SKILL.md +0 -170
  205. package/action/captions/index.ts +0 -227
  206. package/action/edit/SKILL.md +0 -235
  207. package/action/edit/index.ts +0 -493
  208. package/action/image/SKILL.md +0 -140
  209. package/action/image/index.ts +0 -112
  210. package/action/sync/SKILL.md +0 -136
  211. package/action/sync/index.ts +0 -187
  212. package/action/transcribe/SKILL.md +0 -179
  213. package/action/video/SKILL.md +0 -116
  214. package/action/video/index.ts +0 -135
  215. package/action/voice/SKILL.md +0 -125
  216. package/action/voice/index.ts +0 -201
  217. package/index.ts +0 -38
  218. package/lib/README.md +0 -144
  219. package/lib/ai-sdk/fal.ts +0 -106
  220. package/lib/ai-sdk/replicate.ts +0 -107
  221. package/lib/elevenlabs.ts +0 -382
  222. package/lib/fal.ts +0 -478
  223. package/lib/ffmpeg.ts +0 -467
  224. package/lib/fireworks.ts +0 -235
  225. package/lib/groq.ts +0 -246
  226. package/lib/higgsfield.ts +0 -176
  227. package/lib/remotion/SKILL.md +0 -823
  228. package/lib/remotion/cli.ts +0 -115
  229. package/lib/remotion/functions.ts +0 -283
  230. package/lib/remotion/index.ts +0 -19
  231. package/lib/remotion/templates.ts +0 -73
  232. package/lib/replicate.ts +0 -304
  233. package/output.txt +0 -1
  234. package/test-import.ts +0 -7
  235. package/test-services.ts +0 -97
  236. package/utilities/s3.ts +0 -147
package/lib/README.md DELETED
@@ -1,144 +0,0 @@
1
- # lib/ modules
2
-
3
- ## two fal implementations
4
-
5
- ### lib/ai-sdk/fal.ts - ai-sdk provider (recommended for images)
6
-
7
- uses `@ai-sdk/fal` with the vercel ai sdk's `experimental_generateImage`
8
-
9
- **benefits:**
10
- - clean, typed api via vercel ai sdk
11
- - automatic image format handling (uint8array)
12
- - consistent interface with other ai providers
13
- - built-in aspect ratio support
14
- - better for standard image generation
15
-
16
- **example:**
17
- ```bash
18
- bun run lib/ai-sdk/fal.ts generate_image "cyberpunk city" "fal-ai/flux/dev" "16:9"
19
- ```
20
-
21
- **code:**
22
- ```typescript
23
- import { fal } from "@ai-sdk/fal"
24
- import { experimental_generateImage as generateImage } from "ai"
25
-
26
- const { image, providerMetadata } = await generateImage({
27
- model: fal.image("fal-ai/flux/dev"),
28
- prompt: "beautiful sunset",
29
- aspectRatio: "16:9",
30
- })
31
- ```
32
-
33
- ### lib/fal.ts - fal client direct (for video & advanced features)
34
-
35
- uses `@fal-ai/client` directly with the raw fal api
36
-
37
- **benefits:**
38
- - access to all fal features (video, advanced params)
39
- - streaming/queue updates
40
- - full control over api parameters
41
- - required for video generation (no ai-sdk support yet)
42
- - **supports local images** - automatically uploads local files to fal storage
43
-
44
- **examples:**
45
- ```bash
46
- # image generation
47
- bun run lib/fal.ts generate_image "aurora borealis" "fal-ai/flux-pro/v1.1"
48
-
49
- # video from url
50
- bun run lib/fal.ts image_to_video "person talking" "https://image.url" 5
51
-
52
- # video from local file (auto-uploads)
53
- bun run lib/fal.ts image_to_video "ocean waves" "./media/beach.jpg" 10
54
- ```
55
-
56
- **code:**
57
- ```typescript
58
- import { imageToVideo } from "./lib/fal"
59
-
60
- // works with both urls and local files
61
- const result = await imageToVideo({
62
- prompt: "person talking",
63
- imageUrl: "./local/image.jpg", // or "https://..."
64
- duration: 5,
65
- })
66
-
67
- // local files are automatically uploaded to fal storage
68
- ```
69
-
70
- ## when to use which?
71
-
72
- | use case | approach |
73
- |----------|----------|
74
- | standard image generation | ai-sdk provider ✓ |
75
- | video generation | fal client direct ✓ |
76
- | advanced fal features | fal client direct ✓ |
77
- | multi-provider app | ai-sdk provider ✓ |
78
- | custom queue handling | fal client direct ✓ |
79
-
80
- ## higgsfield.ts
81
-
82
- uses `@higgsfield/client` for soul character generation
83
-
84
- **features:**
85
- - generate soul images with custom styles
86
- - create and manage character references
87
- - list available soul styles
88
- - poll for job completion
89
-
90
- **example:**
91
- ```bash
92
- HF_API_KEY=xxx HF_API_SECRET=xxx bun run lib/higgsfield.ts generate_soul "professional headshot"
93
- ```
94
-
95
- ## elevenlabs.ts
96
-
97
- uses `@elevenlabs/elevenlabs-js` for voice, music, and sound effects generation
98
-
99
- **features:**
100
- - text-to-speech with multiple voices
101
- - music generation from text prompts
102
- - sound effects generation
103
- - voice management
104
-
105
- **examples:**
106
- ```bash
107
- # text-to-speech
108
- bun run lib/elevenlabs.ts tts "hello world" rachel output.mp3
109
-
110
- # music generation
111
- bun run lib/elevenlabs.ts music "upbeat electronic dance music" 30000 music.mp3
112
-
113
- # sound effects
114
- bun run lib/elevenlabs.ts sfx "ocean waves crashing" 5 waves.mp3
115
-
116
- # list voices
117
- bun run lib/elevenlabs.ts voices
118
- ```
119
-
120
- **code:**
121
- ```typescript
122
- import { textToSpeech, generateMusic, generateSoundEffect } from "./lib/elevenlabs"
123
-
124
- // voice
125
- const audio = await textToSpeech({
126
- text: "hello world",
127
- voiceId: "rachel",
128
- outputPath: "output.mp3"
129
- })
130
-
131
- // music
132
- const music = await generateMusic({
133
- prompt: "epic orchestral music",
134
- musicLengthMs: 60000,
135
- outputPath: "music.mp3"
136
- })
137
-
138
- // sound effects
139
- const sfx = await generateSoundEffect({
140
- text: "thunder and rain",
141
- durationSeconds: 10,
142
- outputPath: "sfx.mp3"
143
- })
144
- ```
package/lib/ai-sdk/fal.ts DELETED
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * fal.ai wrapper using @ai-sdk/fal provider
4
- * recommended for standard image generation with vercel ai sdk
5
- *
6
- * usage: bun run lib/ai-sdk/fal.ts <command> <args>
7
- */
8
-
9
- import { fal } from "@ai-sdk/fal";
10
- import { experimental_generateImage as generateImageAI } from "ai";
11
-
12
- export async function generateImage(args: {
13
- prompt: string;
14
- model?: string;
15
- aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
16
- }) {
17
- const modelId = args.model || "fal-ai/flux/dev";
18
-
19
- console.log(`[ai-sdk/fal] generating image with ${modelId}`);
20
- console.log(`[ai-sdk/fal] prompt: ${args.prompt}`);
21
- if (args.aspectRatio) {
22
- console.log(`[ai-sdk/fal] aspect ratio: ${args.aspectRatio}`);
23
- }
24
-
25
- try {
26
- const { image, providerMetadata } = await generateImageAI({
27
- model: fal.image(modelId),
28
- prompt: args.prompt,
29
- aspectRatio: args.aspectRatio,
30
- });
31
-
32
- console.log("[ai-sdk/fal] completed!");
33
-
34
- // return in consistent format
35
- return {
36
- image: {
37
- url: image.base64 ? `data:image/png;base64,${image.base64}` : undefined,
38
- uint8Array: image.uint8Array,
39
- },
40
- metadata: providerMetadata?.fal,
41
- };
42
- } catch (error) {
43
- console.error("[ai-sdk/fal] error:", error);
44
- throw error;
45
- }
46
- }
47
-
48
- // cli runner
49
- if (import.meta.main) {
50
- const [command, ...args] = process.argv.slice(2);
51
-
52
- switch (command) {
53
- case "generate_image": {
54
- if (!args[0]) {
55
- console.log(`
56
- usage:
57
- bun run lib/ai-sdk/fal.ts generate_image <prompt> [model] [aspectRatio]
58
-
59
- examples:
60
- bun run lib/ai-sdk/fal.ts generate_image "sunset over ocean" "fal-ai/flux/dev" "16:9"
61
- bun run lib/ai-sdk/fal.ts generate_image "portrait photo" "fal-ai/flux-pro/v1.1" "9:16"
62
-
63
- available models:
64
- - fal-ai/flux/dev (default, fast)
65
- - fal-ai/flux-pro/v1.1 (high quality)
66
- - fal-ai/flux/schnell (very fast)
67
- - fal-ai/ideogram/character (character consistency)
68
- `);
69
- process.exit(1);
70
- }
71
-
72
- const result = await generateImage({
73
- prompt: args[0],
74
- model: args[1],
75
- aspectRatio: args[2] as
76
- | "1:1"
77
- | "16:9"
78
- | "9:16"
79
- | "4:3"
80
- | "3:4"
81
- | undefined,
82
- });
83
-
84
- // save image to file
85
- if (result.image.uint8Array) {
86
- const filename = `/tmp/fal-ai-sdk-${Date.now()}.png`;
87
- await Bun.write(filename, result.image.uint8Array);
88
- console.log(`\nimage saved to: ${filename}`);
89
-
90
- // open image
91
- await Bun.spawn(["open", filename]);
92
- }
93
-
94
- console.log("\nmetadata:");
95
- console.log(JSON.stringify(result.metadata, null, 2));
96
- break;
97
- }
98
-
99
- default:
100
- console.log(`
101
- usage:
102
- bun run lib/ai-sdk/fal.ts generate_image <prompt> [model] [aspectRatio]
103
- `);
104
- process.exit(1);
105
- }
106
- }
@@ -1,107 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * replicate wrapper using @ai-sdk/replicate provider
4
- * recommended for standard image generation with vercel ai sdk
5
- *
6
- * usage: bun run lib/ai-sdk/replicate.ts <command> <args>
7
- */
8
-
9
- import { replicate } from "@ai-sdk/replicate";
10
- import { experimental_generateImage as generateImageAI } from "ai";
11
-
12
- export async function generateImage(args: {
13
- prompt: string;
14
- model?: string;
15
- aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
16
- }) {
17
- const modelId = args.model || "black-forest-labs/flux-dev";
18
-
19
- console.log(`[ai-sdk/replicate] generating image with ${modelId}`);
20
- console.log(`[ai-sdk/replicate] prompt: ${args.prompt}`);
21
- if (args.aspectRatio) {
22
- console.log(`[ai-sdk/replicate] aspect ratio: ${args.aspectRatio}`);
23
- }
24
-
25
- try {
26
- const { image, providerMetadata } = await generateImageAI({
27
- model: replicate.image(modelId),
28
- prompt: args.prompt,
29
- aspectRatio: args.aspectRatio,
30
- });
31
-
32
- console.log("[ai-sdk/replicate] completed!");
33
-
34
- // return in consistent format
35
- return {
36
- image: {
37
- url: image.base64 ? `data:image/png;base64,${image.base64}` : undefined,
38
- uint8Array: image.uint8Array,
39
- },
40
- metadata: providerMetadata?.replicate,
41
- };
42
- } catch (error) {
43
- console.error("[ai-sdk/replicate] error:", error);
44
- throw error;
45
- }
46
- }
47
-
48
- // cli runner
49
- if (import.meta.main) {
50
- const [command, ...args] = process.argv.slice(2);
51
-
52
- switch (command) {
53
- case "generate_image": {
54
- if (!args[0]) {
55
- console.log(`
56
- usage:
57
- bun run lib/ai-sdk/replicate.ts generate_image <prompt> [model] [aspectRatio]
58
-
59
- examples:
60
- bun run lib/ai-sdk/replicate.ts generate_image "sunset over ocean" "black-forest-labs/flux-dev" "16:9"
61
- bun run lib/ai-sdk/replicate.ts generate_image "portrait photo" "black-forest-labs/flux-1.1-pro" "9:16"
62
- bun run lib/ai-sdk/replicate.ts generate_image "cyberpunk city" "black-forest-labs/flux-schnell" "1:1"
63
-
64
- available models:
65
- - black-forest-labs/flux-dev (default, fast)
66
- - black-forest-labs/flux-1.1-pro (high quality)
67
- - black-forest-labs/flux-schnell (very fast)
68
- - stability-ai/sdxl (stable diffusion xl)
69
- `);
70
- process.exit(1);
71
- }
72
-
73
- const result = await generateImage({
74
- prompt: args[0],
75
- model: args[1],
76
- aspectRatio: args[2] as
77
- | "1:1"
78
- | "16:9"
79
- | "9:16"
80
- | "4:3"
81
- | "3:4"
82
- | undefined,
83
- });
84
-
85
- // save image to file
86
- if (result.image.uint8Array) {
87
- const filename = `/tmp/replicate-ai-sdk-${Date.now()}.png`;
88
- await Bun.write(filename, result.image.uint8Array);
89
- console.log(`\nimage saved to: ${filename}`);
90
-
91
- // open image
92
- await Bun.spawn(["open", filename]);
93
- }
94
-
95
- console.log("\nmetadata:");
96
- console.log(JSON.stringify(result.metadata, null, 2));
97
- break;
98
- }
99
-
100
- default:
101
- console.log(`
102
- usage:
103
- bun run lib/ai-sdk/replicate.ts generate_image <prompt> [model] [aspectRatio]
104
- `);
105
- process.exit(1);
106
- }
107
- }