@neta-art/generation 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/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/builtins-BuI-rf8X.d.ts +137 -0
- package/dist/builtins-BuI-rf8X.d.ts.map +1 -0
- package/dist/builtins-hmNIcYXN.js +311 -0
- package/dist/builtins-hmNIcYXN.js.map +1 -0
- package/dist/builtins.d.ts +2 -0
- package/dist/builtins.js +3 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +65 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/export-config-ZxwkQoZ6.js +128 -0
- package/dist/export-config-ZxwkQoZ6.js.map +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +602 -0
- package/dist/index.js.map +1 -0
- package/models/gemini-3.1-flash-image-preview.yaml +62 -0
- package/models/gpt-image-2.yaml +56 -0
- package/models/seedance-2-0-fast.yaml +97 -0
- package/models/seedance-2-0.yaml +97 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Neta Art
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# @neta-art/generation
|
|
2
|
+
|
|
3
|
+
A lightweight multimodal generation SDK with built-in model presets, model declaration files, and adapter-based provider calls.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @neta-art/generation
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createGenerationClient } from "@neta-art/generation";
|
|
15
|
+
|
|
16
|
+
const client = createGenerationClient({
|
|
17
|
+
apiKey: process.env.NETA_ROUTER_API_KEY!,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const output = await client.generate({
|
|
21
|
+
model: "gpt-image-2",
|
|
22
|
+
content: [
|
|
23
|
+
{ type: "text", text: "a cinematic portrait of a robot florist, 35mm film" },
|
|
24
|
+
],
|
|
25
|
+
parameters: {
|
|
26
|
+
size: "1024x1024",
|
|
27
|
+
quality: "high",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(output);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`baseUrl` defaults to `https://router.neta.art`. Pass a different endpoint when needed:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const client = createGenerationClient({
|
|
38
|
+
apiKey: process.env.NETA_ROUTER_API_KEY!,
|
|
39
|
+
baseUrl: "https://router.neta.art",
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Local testing with `.env`
|
|
44
|
+
|
|
45
|
+
`.env` is ignored by Git. Copy `.env.example` to `.env` and fill in your router key:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cp .env.example .env
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```dotenv
|
|
52
|
+
NETA_ROUTER_API_KEY=your_api_key_here
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Node.js does not load `.env` automatically for library code. The example scripts use Node's native `--env-file` flag through npm scripts:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pnpm example:basic-image
|
|
59
|
+
pnpm example:image-editing
|
|
60
|
+
pnpm example:text-to-video
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Built-in models
|
|
64
|
+
|
|
65
|
+
- `gpt-image-2`
|
|
66
|
+
- `gemini-3.1-flash-image-preview`
|
|
67
|
+
- `seedance-2-0`
|
|
68
|
+
- `seedance-2-0-fast`
|
|
69
|
+
|
|
70
|
+
Built-in model declarations share the same client-level `apiKey` and `baseUrl`.
|
|
71
|
+
|
|
72
|
+
## Image editing with a reference image
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const output = await client.generate({
|
|
76
|
+
model: "gemini-3.1-flash-image-preview",
|
|
77
|
+
content: [
|
|
78
|
+
{ type: "text", text: "turn this portrait into a watercolor illustration" },
|
|
79
|
+
{ type: "image", source: { type: "url", url: "https://example.com/portrait.jpg" } },
|
|
80
|
+
],
|
|
81
|
+
parameters: {
|
|
82
|
+
aspect_ratio: "3:4",
|
|
83
|
+
image_size: "2K",
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Video generation
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const output = await client.generate({
|
|
92
|
+
model: "seedance-2-0-fast",
|
|
93
|
+
content: [
|
|
94
|
+
{ type: "text", text: "a cat playing piano in a cozy jazz club, cinematic lighting" },
|
|
95
|
+
],
|
|
96
|
+
parameters: {
|
|
97
|
+
duration: 5,
|
|
98
|
+
resolution: "720p",
|
|
99
|
+
aspect_ratio: "16:9",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Frame and reference-image video modes use `meta.role`:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
await client.generate({
|
|
108
|
+
model: "seedance-2-0",
|
|
109
|
+
content: [
|
|
110
|
+
{ type: "text", text: "create a smooth dramatic transition" },
|
|
111
|
+
{ type: "image", source: { type: "url", url: "https://example.com/start.jpg" }, meta: { role: "first_frame" } },
|
|
112
|
+
{ type: "image", source: { type: "url", url: "https://example.com/end.jpg" }, meta: { role: "last_frame" } },
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Load model declarations from files
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { createGenerationClientFromDirectory } from "@neta-art/generation";
|
|
121
|
+
|
|
122
|
+
const client = await createGenerationClientFromDirectory("./models", {
|
|
123
|
+
apiKey: process.env.NETA_ROUTER_API_KEY!,
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Supported declaration formats:
|
|
128
|
+
|
|
129
|
+
- `.yaml`
|
|
130
|
+
- `.yml`
|
|
131
|
+
- `.json`
|
|
132
|
+
|
|
133
|
+
Custom declarations are merged with built-in models by default. If the same `model` exists, the custom declaration wins.
|
|
134
|
+
|
|
135
|
+
## Export model declarations
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { exportBuiltinModelConfig } from "@neta-art/generation";
|
|
139
|
+
|
|
140
|
+
await exportBuiltinModelConfig("gpt-image-2", "./gpt-image-2.yaml");
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
CLI:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
neta-generation models list
|
|
147
|
+
neta-generation models export gpt-image-2 --out ./gpt-image-2.yaml
|
|
148
|
+
neta-generation models export-all --out ./models
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Model declaration schema
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
schema: neta.generation.model.v1
|
|
155
|
+
model: gpt-image-2
|
|
156
|
+
title: GPT Image 2
|
|
157
|
+
adapter:
|
|
158
|
+
type: openai.images
|
|
159
|
+
content:
|
|
160
|
+
input:
|
|
161
|
+
- type: text
|
|
162
|
+
required: true
|
|
163
|
+
min: 1
|
|
164
|
+
max: 16
|
|
165
|
+
merge: newline
|
|
166
|
+
- type: image
|
|
167
|
+
required: false
|
|
168
|
+
max: 16
|
|
169
|
+
sources:
|
|
170
|
+
- url
|
|
171
|
+
- base64
|
|
172
|
+
parameters:
|
|
173
|
+
size:
|
|
174
|
+
type: string
|
|
175
|
+
optional: true
|
|
176
|
+
default: 1024x1024
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Adapter credentials are intentionally not stored in model declarations. Use client-level or request-level `apiKey` and `baseUrl` instead.
|
|
180
|
+
|
|
181
|
+
## Content sources
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
type GenerationSource =
|
|
185
|
+
| { type: "url"; url: string }
|
|
186
|
+
| { type: "base64"; mediaType: string; data: string };
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Adapter types
|
|
190
|
+
|
|
191
|
+
Built-in adapters:
|
|
192
|
+
|
|
193
|
+
- `openai.images`
|
|
194
|
+
- `gemini.generateContent`
|
|
195
|
+
- `ark.videoGenerations`
|
|
196
|
+
|
|
197
|
+
You can register custom adapters:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const client = createGenerationClient({
|
|
201
|
+
apiKey,
|
|
202
|
+
adapters: {
|
|
203
|
+
"custom.adapter": async (input) => {
|
|
204
|
+
return [];
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Validation without provider calls
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const resolved = client.validate({
|
|
214
|
+
model: "gpt-image-2",
|
|
215
|
+
content: [{ type: "text", text: "hello" }],
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
console.log(resolved.parameters);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Error handling
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { GenerationValidationError, GenerationProviderError } from "@neta-art/generation";
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
await client.generate(request);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
if (error instanceof GenerationValidationError) {
|
|
230
|
+
console.error("Invalid request", error.message);
|
|
231
|
+
} else if (error instanceof GenerationProviderError) {
|
|
232
|
+
console.error("Provider failed", error.message);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
declare const MODEL_SCHEMA: "neta.generation.model.v1";
|
|
3
|
+
type GenerationSource = {
|
|
4
|
+
type: "url";
|
|
5
|
+
url: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "base64";
|
|
8
|
+
mediaType: string;
|
|
9
|
+
data: string;
|
|
10
|
+
};
|
|
11
|
+
type GenerationContentBlockMeta = Record<string, unknown>;
|
|
12
|
+
type GenerationContentBlock = {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
meta?: GenerationContentBlockMeta;
|
|
16
|
+
} | {
|
|
17
|
+
type: "image";
|
|
18
|
+
source: GenerationSource;
|
|
19
|
+
meta?: GenerationContentBlockMeta;
|
|
20
|
+
} | {
|
|
21
|
+
type: "video";
|
|
22
|
+
source: GenerationSource;
|
|
23
|
+
meta?: GenerationContentBlockMeta;
|
|
24
|
+
} | {
|
|
25
|
+
type: "audio";
|
|
26
|
+
source: GenerationSource;
|
|
27
|
+
meta?: GenerationContentBlockMeta;
|
|
28
|
+
};
|
|
29
|
+
type GenerationContentSpec = {
|
|
30
|
+
type: "text" | "image" | "video" | "audio";
|
|
31
|
+
required?: boolean;
|
|
32
|
+
min?: number;
|
|
33
|
+
max?: number;
|
|
34
|
+
sources?: Array<GenerationSource["type"]>;
|
|
35
|
+
merge?: "newline" | "space" | "concat";
|
|
36
|
+
meta?: Record<string, unknown>;
|
|
37
|
+
description?: string;
|
|
38
|
+
};
|
|
39
|
+
type GenerationParameterSpec = {
|
|
40
|
+
type: "string";
|
|
41
|
+
optional?: boolean;
|
|
42
|
+
default?: string;
|
|
43
|
+
enum?: string[];
|
|
44
|
+
description?: string;
|
|
45
|
+
examples?: string[];
|
|
46
|
+
} | {
|
|
47
|
+
type: "number";
|
|
48
|
+
optional?: boolean;
|
|
49
|
+
default?: number;
|
|
50
|
+
min?: number;
|
|
51
|
+
max?: number;
|
|
52
|
+
description?: string;
|
|
53
|
+
examples?: number[];
|
|
54
|
+
} | {
|
|
55
|
+
type: "integer";
|
|
56
|
+
optional?: boolean;
|
|
57
|
+
default?: number;
|
|
58
|
+
min?: number;
|
|
59
|
+
max?: number;
|
|
60
|
+
description?: string;
|
|
61
|
+
examples?: number[];
|
|
62
|
+
} | {
|
|
63
|
+
type: "boolean";
|
|
64
|
+
optional?: boolean;
|
|
65
|
+
default?: boolean;
|
|
66
|
+
description?: string;
|
|
67
|
+
examples?: boolean[];
|
|
68
|
+
};
|
|
69
|
+
type GenerationModelDeclaration = {
|
|
70
|
+
schema: typeof MODEL_SCHEMA;
|
|
71
|
+
model: string;
|
|
72
|
+
title?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
adapter: {
|
|
75
|
+
type: string;
|
|
76
|
+
};
|
|
77
|
+
content: {
|
|
78
|
+
input: GenerationContentSpec[];
|
|
79
|
+
};
|
|
80
|
+
parameters?: Record<string, GenerationParameterSpec>;
|
|
81
|
+
examples?: Array<{
|
|
82
|
+
title?: string;
|
|
83
|
+
request: GenerateRequest;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
type GenerateRequest = {
|
|
87
|
+
model: string;
|
|
88
|
+
content: GenerationContentBlock[];
|
|
89
|
+
parameters?: Record<string, unknown>;
|
|
90
|
+
apiKey?: string;
|
|
91
|
+
baseUrl?: string;
|
|
92
|
+
metadata?: Record<string, unknown>;
|
|
93
|
+
};
|
|
94
|
+
type ResolvedGenerationRequest = {
|
|
95
|
+
declaration: GenerationModelDeclaration;
|
|
96
|
+
request: GenerateRequest;
|
|
97
|
+
parameters: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
type GenerationSourceResolver = (source: GenerationSource) => Promise<string> | string;
|
|
100
|
+
type GenerationAdapterContext = {
|
|
101
|
+
apiKey: string;
|
|
102
|
+
baseUrl: string;
|
|
103
|
+
fetch: typeof fetch;
|
|
104
|
+
resolveSource: GenerationSourceResolver;
|
|
105
|
+
};
|
|
106
|
+
type GenerationAdapterInput = ResolvedGenerationRequest & {
|
|
107
|
+
context: GenerationAdapterContext;
|
|
108
|
+
};
|
|
109
|
+
type GenerationAdapter = (input: GenerationAdapterInput) => Promise<GenerationContentBlock[]>;
|
|
110
|
+
type CreateGenerationClientOptions = {
|
|
111
|
+
apiKey?: string;
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
models?: GenerationModelDeclaration[];
|
|
114
|
+
includeBuiltinModels?: boolean;
|
|
115
|
+
fetch?: typeof fetch;
|
|
116
|
+
sourceResolver?: GenerationSourceResolver;
|
|
117
|
+
adapters?: Record<string, GenerationAdapter>;
|
|
118
|
+
};
|
|
119
|
+
type GenerationClient = {
|
|
120
|
+
generate(request: GenerateRequest): Promise<GenerationContentBlock[]>;
|
|
121
|
+
validate(request: GenerateRequest): ResolvedGenerationRequest;
|
|
122
|
+
listModels(): GenerationModelDeclaration[];
|
|
123
|
+
getModel(model: string): GenerationModelDeclaration | null;
|
|
124
|
+
stringifyModelConfig(model: string, options?: {
|
|
125
|
+
format?: "yaml" | "json";
|
|
126
|
+
}): string;
|
|
127
|
+
exportModelConfig(model: string, filePath: string): Promise<void>;
|
|
128
|
+
exportModelConfigs(directory: string): Promise<void>;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/builtins.d.ts
|
|
132
|
+
declare const builtinGenerationModels: GenerationModelDeclaration[];
|
|
133
|
+
declare function getBuiltinGenerationModel(model: string): GenerationModelDeclaration | null;
|
|
134
|
+
declare function listBuiltinGenerationModels(): GenerationModelDeclaration[];
|
|
135
|
+
//#endregion
|
|
136
|
+
export { MODEL_SCHEMA as _, GenerateRequest as a, GenerationAdapterInput as c, GenerationContentBlockMeta as d, GenerationContentSpec as f, GenerationSourceResolver as g, GenerationSource as h, CreateGenerationClientOptions as i, GenerationClient as l, GenerationParameterSpec as m, getBuiltinGenerationModel as n, GenerationAdapter as o, GenerationModelDeclaration as p, listBuiltinGenerationModels as r, GenerationAdapterContext as s, builtinGenerationModels as t, GenerationContentBlock as u, ResolvedGenerationRequest as v };
|
|
137
|
+
//# sourceMappingURL=builtins-BuI-rf8X.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-BuI-rf8X.d.ts","names":[],"sources":["../src/types.ts","../src/builtins.ts"],"sourcesContent":[],"mappings":"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"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
const MODEL_SCHEMA = "neta.generation.model.v1";
|
|
3
|
+
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/utils.ts
|
|
6
|
+
function cloneJson(value) {
|
|
7
|
+
return JSON.parse(JSON.stringify(value));
|
|
8
|
+
}
|
|
9
|
+
function slugifyFileName(value) {
|
|
10
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "model";
|
|
11
|
+
}
|
|
12
|
+
function getBlockMeta(block) {
|
|
13
|
+
return "meta" in block ? block.meta : void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/builtins.ts
|
|
18
|
+
const imageSizeParameters = {
|
|
19
|
+
size: {
|
|
20
|
+
type: "string",
|
|
21
|
+
optional: true,
|
|
22
|
+
default: "1024x1024",
|
|
23
|
+
description: "Output image size.",
|
|
24
|
+
examples: [
|
|
25
|
+
"auto",
|
|
26
|
+
"1024x1024",
|
|
27
|
+
"1536x1024",
|
|
28
|
+
"1024x1536",
|
|
29
|
+
"2048x2048",
|
|
30
|
+
"2048x1152",
|
|
31
|
+
"3840x2160",
|
|
32
|
+
"2160x3840"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
quality: {
|
|
36
|
+
type: "string",
|
|
37
|
+
optional: true,
|
|
38
|
+
default: "auto",
|
|
39
|
+
enum: [
|
|
40
|
+
"auto",
|
|
41
|
+
"low",
|
|
42
|
+
"medium",
|
|
43
|
+
"high"
|
|
44
|
+
],
|
|
45
|
+
description: "Image quality."
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function videoParameters(defaults) {
|
|
49
|
+
return {
|
|
50
|
+
duration: {
|
|
51
|
+
type: "integer",
|
|
52
|
+
optional: true,
|
|
53
|
+
default: 5,
|
|
54
|
+
min: 4,
|
|
55
|
+
max: 15,
|
|
56
|
+
description: "Video duration in seconds."
|
|
57
|
+
},
|
|
58
|
+
resolution: {
|
|
59
|
+
type: "string",
|
|
60
|
+
optional: true,
|
|
61
|
+
default: defaults.resolution,
|
|
62
|
+
enum: [
|
|
63
|
+
"480p",
|
|
64
|
+
"720p",
|
|
65
|
+
"1080p",
|
|
66
|
+
"2K"
|
|
67
|
+
],
|
|
68
|
+
description: "Output video resolution."
|
|
69
|
+
},
|
|
70
|
+
aspect_ratio: {
|
|
71
|
+
type: "string",
|
|
72
|
+
optional: true,
|
|
73
|
+
default: "16:9",
|
|
74
|
+
enum: [
|
|
75
|
+
"16:9",
|
|
76
|
+
"9:16",
|
|
77
|
+
"1:1",
|
|
78
|
+
"4:3",
|
|
79
|
+
"3:2",
|
|
80
|
+
"2:3",
|
|
81
|
+
"3:4",
|
|
82
|
+
"21:9",
|
|
83
|
+
"adaptive"
|
|
84
|
+
],
|
|
85
|
+
description: "Output aspect ratio. Use adaptive to let the model choose."
|
|
86
|
+
},
|
|
87
|
+
fps: {
|
|
88
|
+
type: "integer",
|
|
89
|
+
optional: true,
|
|
90
|
+
default: 30,
|
|
91
|
+
min: 1,
|
|
92
|
+
max: 60,
|
|
93
|
+
description: "Frames per second."
|
|
94
|
+
},
|
|
95
|
+
seed: {
|
|
96
|
+
type: "integer",
|
|
97
|
+
optional: true,
|
|
98
|
+
description: "Random seed for reproducibility."
|
|
99
|
+
},
|
|
100
|
+
generate_audio: {
|
|
101
|
+
type: "boolean",
|
|
102
|
+
optional: true,
|
|
103
|
+
default: true,
|
|
104
|
+
description: "Generate synchronized audio."
|
|
105
|
+
},
|
|
106
|
+
return_last_frame: {
|
|
107
|
+
type: "boolean",
|
|
108
|
+
optional: true,
|
|
109
|
+
default: true,
|
|
110
|
+
description: "Return the last frame as an image for chaining video segments."
|
|
111
|
+
},
|
|
112
|
+
camera_fixed: {
|
|
113
|
+
type: "boolean",
|
|
114
|
+
optional: true,
|
|
115
|
+
default: false,
|
|
116
|
+
description: "Fix camera position when supported."
|
|
117
|
+
},
|
|
118
|
+
watermark: {
|
|
119
|
+
type: "boolean",
|
|
120
|
+
optional: true,
|
|
121
|
+
default: false,
|
|
122
|
+
description: "Add AI Generated watermark."
|
|
123
|
+
},
|
|
124
|
+
poll_interval: {
|
|
125
|
+
type: "integer",
|
|
126
|
+
optional: true,
|
|
127
|
+
default: 2,
|
|
128
|
+
min: 1,
|
|
129
|
+
max: 30,
|
|
130
|
+
description: "Seconds between task status checks."
|
|
131
|
+
},
|
|
132
|
+
max_wait: {
|
|
133
|
+
type: "integer",
|
|
134
|
+
optional: true,
|
|
135
|
+
default: defaults.maxWait,
|
|
136
|
+
min: 30,
|
|
137
|
+
max: 1800,
|
|
138
|
+
description: "Maximum seconds to wait for task completion."
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const builtinModels = [
|
|
143
|
+
{
|
|
144
|
+
schema: MODEL_SCHEMA,
|
|
145
|
+
model: "gpt-image-2",
|
|
146
|
+
title: "GPT Image 2",
|
|
147
|
+
description: "Image generation model with optional reference images. Good for photorealistic scenes, detailed images, and image editing with references.",
|
|
148
|
+
adapter: { type: "openai.images" },
|
|
149
|
+
content: { input: [{
|
|
150
|
+
type: "text",
|
|
151
|
+
required: true,
|
|
152
|
+
min: 1,
|
|
153
|
+
max: 16,
|
|
154
|
+
merge: "newline",
|
|
155
|
+
description: "Prompt text."
|
|
156
|
+
}, {
|
|
157
|
+
type: "image",
|
|
158
|
+
required: false,
|
|
159
|
+
max: 16,
|
|
160
|
+
sources: ["url", "base64"],
|
|
161
|
+
description: "Optional reference images."
|
|
162
|
+
}] },
|
|
163
|
+
parameters: imageSizeParameters,
|
|
164
|
+
examples: [{
|
|
165
|
+
title: "Basic image",
|
|
166
|
+
request: {
|
|
167
|
+
model: "gpt-image-2",
|
|
168
|
+
content: [{
|
|
169
|
+
type: "text",
|
|
170
|
+
text: "a cyberpunk cat in neon rain"
|
|
171
|
+
}],
|
|
172
|
+
parameters: {
|
|
173
|
+
size: "1024x1024",
|
|
174
|
+
quality: "auto"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
schema: MODEL_SCHEMA,
|
|
181
|
+
model: "gemini-3.1-flash-image-preview",
|
|
182
|
+
title: "Gemini 3.1 Flash Image Preview",
|
|
183
|
+
description: "Gemini image generation and editing model. Good for text rendering, infographics, style transfer, and iterative image editing with references.",
|
|
184
|
+
adapter: { type: "gemini.generateContent" },
|
|
185
|
+
content: { input: [{
|
|
186
|
+
type: "text",
|
|
187
|
+
required: true,
|
|
188
|
+
min: 1,
|
|
189
|
+
max: 16,
|
|
190
|
+
merge: "newline",
|
|
191
|
+
description: "Prompt text."
|
|
192
|
+
}, {
|
|
193
|
+
type: "image",
|
|
194
|
+
required: false,
|
|
195
|
+
max: 14,
|
|
196
|
+
sources: ["url", "base64"],
|
|
197
|
+
description: "Optional reference images."
|
|
198
|
+
}] },
|
|
199
|
+
parameters: {
|
|
200
|
+
aspect_ratio: {
|
|
201
|
+
type: "string",
|
|
202
|
+
optional: true,
|
|
203
|
+
default: "1:1",
|
|
204
|
+
enum: [
|
|
205
|
+
"1:1",
|
|
206
|
+
"16:9",
|
|
207
|
+
"4:3",
|
|
208
|
+
"3:2",
|
|
209
|
+
"3:4",
|
|
210
|
+
"2:3",
|
|
211
|
+
"9:16",
|
|
212
|
+
"5:4",
|
|
213
|
+
"4:5",
|
|
214
|
+
"21:9",
|
|
215
|
+
"1:4",
|
|
216
|
+
"4:1",
|
|
217
|
+
"1:8",
|
|
218
|
+
"8:1"
|
|
219
|
+
],
|
|
220
|
+
description: "Output aspect ratio."
|
|
221
|
+
},
|
|
222
|
+
image_size: {
|
|
223
|
+
type: "string",
|
|
224
|
+
optional: true,
|
|
225
|
+
default: "2K",
|
|
226
|
+
enum: [
|
|
227
|
+
"512",
|
|
228
|
+
"1K",
|
|
229
|
+
"2K",
|
|
230
|
+
"4K"
|
|
231
|
+
],
|
|
232
|
+
description: "Output image resolution."
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
examples: [{
|
|
236
|
+
title: "Basic image",
|
|
237
|
+
request: {
|
|
238
|
+
model: "gemini-3.1-flash-image-preview",
|
|
239
|
+
content: [{
|
|
240
|
+
type: "text",
|
|
241
|
+
text: "a vibrant infographic explaining photosynthesis with clear readable labels"
|
|
242
|
+
}],
|
|
243
|
+
parameters: {
|
|
244
|
+
aspect_ratio: "16:9",
|
|
245
|
+
image_size: "1K"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
schema: MODEL_SCHEMA,
|
|
252
|
+
model: "seedance-2-0",
|
|
253
|
+
title: "Seedance 2.0",
|
|
254
|
+
description: "Higher quality Ark video generation model for final production outputs.",
|
|
255
|
+
adapter: { type: "ark.videoGenerations" },
|
|
256
|
+
content: { input: [{
|
|
257
|
+
type: "text",
|
|
258
|
+
required: true,
|
|
259
|
+
min: 1,
|
|
260
|
+
max: 16,
|
|
261
|
+
merge: "newline",
|
|
262
|
+
description: "Video prompt."
|
|
263
|
+
}, {
|
|
264
|
+
type: "image",
|
|
265
|
+
required: false,
|
|
266
|
+
max: 9,
|
|
267
|
+
sources: ["url", "base64"],
|
|
268
|
+
description: "Optional image input. Use meta.role as first_frame, last_frame, or reference_image."
|
|
269
|
+
}] },
|
|
270
|
+
parameters: videoParameters({
|
|
271
|
+
resolution: "1080p",
|
|
272
|
+
maxWait: 900
|
|
273
|
+
})
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
schema: MODEL_SCHEMA,
|
|
277
|
+
model: "seedance-2-0-fast",
|
|
278
|
+
title: "Seedance 2.0 Fast",
|
|
279
|
+
description: "Fast Ark video generation model for drafts, rapid iteration, text-to-video, image-to-video, and reference-guided video generation.",
|
|
280
|
+
adapter: { type: "ark.videoGenerations" },
|
|
281
|
+
content: { input: [{
|
|
282
|
+
type: "text",
|
|
283
|
+
required: true,
|
|
284
|
+
min: 1,
|
|
285
|
+
max: 16,
|
|
286
|
+
merge: "newline",
|
|
287
|
+
description: "Video prompt."
|
|
288
|
+
}, {
|
|
289
|
+
type: "image",
|
|
290
|
+
required: false,
|
|
291
|
+
max: 9,
|
|
292
|
+
sources: ["url", "base64"],
|
|
293
|
+
description: "Optional image input. Use meta.role as first_frame, last_frame, or reference_image."
|
|
294
|
+
}] },
|
|
295
|
+
parameters: videoParameters({
|
|
296
|
+
resolution: "720p",
|
|
297
|
+
maxWait: 600
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
];
|
|
301
|
+
const builtinGenerationModels = cloneJson(builtinModels);
|
|
302
|
+
function getBuiltinGenerationModel(model) {
|
|
303
|
+
return cloneJson(builtinModels.find((declaration) => declaration.model === model) ?? null);
|
|
304
|
+
}
|
|
305
|
+
function listBuiltinGenerationModels() {
|
|
306
|
+
return cloneJson(builtinModels);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//#endregion
|
|
310
|
+
export { getBlockMeta as a, cloneJson as i, getBuiltinGenerationModel as n, slugifyFileName as o, listBuiltinGenerationModels as r, MODEL_SCHEMA as s, builtinGenerationModels as t };
|
|
311
|
+
//# sourceMappingURL=builtins-hmNIcYXN.js.map
|