@mindstone/mcp-server-runway 0.6.0 → 0.7.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
@@ -7,7 +7,7 @@ Runway ML MCP server for Model Context Protocol hosts. Generate AI video, images
7
7
 
8
8
  ## Status
9
9
 
10
- - **Version:** [0.6.0](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
10
+ - **Version:** [0.7.0](./CHANGELOG.md) · [npm](https://www.npmjs.com/package/@mindstone/mcp-server-runway)
11
11
  - **Auth:** API key ([`RUNWAYML_API_SECRET`](./server.json))
12
12
  - **Tools:** [23](./src/tools/) (video, image, audio, voices, tasks)
13
13
  - **Surface:** cloud-api
@@ -130,11 +130,11 @@ node dist/index.js
130
130
  - `character_performance` — Animate a character with facial expressions and body movements (Act-Two)
131
131
  - `upscale_video` — Upscale a video up to 4K (Magnific Video Upscaler)
132
132
 
133
- Video models: `generate_video_from_image` takes `gen4_turbo` (default), `gen4.5`, `veo3.1`, `veo3.1_fast`, `kling_4` (Kling 4.0) or `seedance2_5` (Seedance 2.5); `generate_video_from_text` takes `gen4.5` (default), `veo3.1`, `veo3.1_fast`, `kling_4` or `seedance2_5`. `veo3` is no longer accepted by Runway and is refused before any request; use `veo3.1` or `veo3.1_fast` instead.
133
+ Video models: `generate_video_from_image` takes `gen4_turbo` (default), `gen4.5`, `veo3.1` and `veo3.1_fast`; `generate_video_from_text` takes `gen4.5` (default), `veo3.1` and `veo3.1_fast`. Both also take the models Runway resells: `kling_4` and `kling_4_flash` (Kling 4.0), `seedance2_5` and `seedance2_5_flash` (Seedance 2.5), `gemini_omni_flash_1.2` (Gemini Omni Flash), `hailuo3` and `h3_max` (MiniMax), `wan3` and `wan3_prime` (Wan 3), `grok_imagine_1_5` and `grok_imagine_1_5_lite` (Grok Imagine), and `happyhorse_1_0`. Some of these take a `resolution` (`hailuo3`, `h3_max`, `grok_imagine_1_5`, and `happyhorse_1_0` from an image) instead of, or as well as, a `ratio`. `veo3` is no longer accepted by Runway and is refused before any request; use `veo3.1` or `veo3.1_fast` instead.
134
134
 
135
- Image models: `gen4_image` (default), `gen4_image_turbo`, `gemini_2.5_flash`, `gemini_image3_pro` (Nano Banana Pro), `gpt_image_2_6_sunburst` and `gpt_image_2_6_flare` (GPT Image 2.6). Speech models: `eleven_multilingual_v2` (default), `eleven_v3` and `eleven_v4`.
135
+ Image models: `gen4_image` (default), `gen4_image_turbo`, `gemini_2.5_flash`, `gemini_image3_pro` (Nano Banana Pro), `gpt_image_2_6_sunburst` and `gpt_image_2_6_flare` (GPT Image 2.6), `gemini_image3.1_flash` and `gemini_image3.1_flash_lite`, `nano_banana_2.1`, `seedream5.5`, `minimax_h3_image`, `ideogram_4_5`, `grok_imagine_image_2`, `muse_image` and `bria_fibo_1_5`. Speech models: `eleven_multilingual_v2` (default), `eleven_v3` and `eleven_v4`.
136
136
 
137
- Each model takes its own ratios, durations and options; anything a model does not take is refused before any request. The models Runway resells from other makers (Kling, Seedance, Nano Banana, GPT Image, ElevenLabs v4) were added from Runway's documentation and have not yet been tried against its live API.
137
+ Each model takes its own ratios, durations and options; anything a model does not take is refused before any request. The models Runway resells from other makers (all of the above besides `gen4*`, `veo3.1*` and `gemini_2.5_flash`, plus ElevenLabs v4) were added from Runway's documentation and have not yet been tried against its live API, so a mistake fails for that model only. Their accepted fields and limits are generated from Runway's published API spec: `node scripts/generate-resold-specs.mjs <openapi.json>` rewrites `src/tools/resold-specs.generated.ts`, and `--check` compares it; defaults and prices are kept by hand in `src/tools/resold-models.ts`.
138
138
 
139
139
  ### Image
140
140
  - `generate_image` — Generate an image from text, optionally with reference images
@@ -69,7 +69,7 @@ export function registerAudioTools(server) {
69
69
  // ── Sound Effect ──────────────────────────────────────────────────────
70
70
  server.registerTool('generate_sound_effect', {
71
71
  description: 'Generate sound effects from a text description. ' +
72
- 'COST: 1 credit per 6 seconds. WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
72
+ 'COST: 1 credit per second of audio, or 2 credits when the duration is left out. WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
73
73
  inputSchema: z.object({
74
74
  prompt_text: z.string().max(3000).describe('Describe the sound effect. Max 3000 chars.'),
75
75
  duration: z.number().optional().describe('Duration in seconds (0.5-30). Auto-determined if omitted.'),
@@ -85,7 +85,7 @@ export function registerAudioTools(server) {
85
85
  const result = await runwayFetch('/sound_effect', { method: 'POST', body: JSON.stringify(body) });
86
86
  return JSON.stringify({
87
87
  ok: true, task_id: result.id, status: 'PENDING',
88
- cost_rate: '1 credit per 6s of audio',
88
+ cost_rate: args.duration !== undefined ? '1 credit per second of audio' : '2 credits',
89
89
  message: `Sound effect generation started. Poll with check_runway_task("${result.id}") every 10s, or use wait_for_runway_task.`,
90
90
  });
91
91
  }));
@@ -3,33 +3,35 @@ import { z } from 'zod';
3
3
  import { runwayFetch, resolveMediaInput, addContentModeration } from '../client.js';
4
4
  import { RunwayError } from '../types.js';
5
5
  import { withErrorHandling } from '../utils.js';
6
- import { IMAGE_SPECS, isResoldImageModel, resoldImageFields } from './resold-models.js';
7
- // Runway's own and Gemini 2.5 models keep the ratios they always took; the
8
- // tool's ratio list also carries the resold models' ratios, so these are checked here.
6
+ import { RESOLD_IMAGE_MODELS, isResoldImageModel, resoldImageFields } from './resold-models.js';
7
+ // Runway's own and Gemini 2.5 models keep the ratios they always took; each
8
+ // resold model's ratios are checked against its own spec in resold-models.ts.
9
9
  const RUNWAY_IMAGE_RATIOS = [
10
10
  '1024:1024', '1080:1080', '1168:880', '1360:768', '1440:1080',
11
11
  '1080:1440', '1808:768', '1920:1080', '1080:1920', '2112:912',
12
12
  '1280:720', '720:1280', '720:720', '960:720', '720:960', '1680:720',
13
13
  ];
14
- const IMAGE_RATIOS = [...new Set([
15
- ...RUNWAY_IMAGE_RATIOS, ...IMAGE_SPECS.gemini_image3_pro.ratios, ...IMAGE_SPECS.gpt_image_2_6_sunburst.ratios,
16
- ])];
17
14
  export function registerImageTools(server) {
18
15
  server.registerTool('generate_image', {
19
16
  description: 'Generate an image from text, optionally with reference images for style/content guidance. ' +
20
17
  'MODELS: gen4_image (high quality), gen4_image_turbo (fast/cheap), gemini_2.5_flash (Google Gemini), ' +
21
- 'gemini_image3_pro (Nano Banana Pro, up to 4K), gpt_image_2_6_sunburst and gpt_image_2_6_flare (OpenAI GPT Image 2.6, up to 4K). ' +
22
- 'REFERENCE IMAGES: Tag with short label (e.g., "cat"), use @tag in prompt. gpt_image_2_6 models ignore tags: refer to references by order ("the first image"). ' +
18
+ 'gemini_image3_pro (Nano Banana Pro, up to 4K), gpt_image_2_6_sunburst and gpt_image_2_6_flare (OpenAI GPT Image 2.6, up to 4K), ' +
19
+ 'gemini_image3.1_flash (512px to 4K), gemini_image3.1_flash_lite (1K, cheap), nano_banana_2.1 (1K to 4K), seedream5.5 (ByteDance, 1K to 2K), ' +
20
+ 'minimax_h3_image (1K to 4K, up to 16 references), ideogram_4_5 (strong at text in images), grok_imagine_image_2 (xAI, 1K/2K), ' +
21
+ 'muse_image (cheapest, 1 credit), bria_fibo_1_5 (1MP/4MP, takes a seed). ' +
22
+ 'Models made by others take only their own options; a wrong one is refused with the reason, nothing is charged. Their prices are estimated from Runway\'s published rates. ' +
23
+ 'REFERENCE IMAGES: Tag with short label (e.g., "cat"), use @tag in prompt. Tags work with gen4, gemini and nano_banana models. ' +
24
+ 'gpt_image_2_6 takes tags but ignores them, and the other models made by others refuse them: with those, refer to references by order ("the first image"). ' +
23
25
  'WORKFLOW: Returns task_id → poll with check_runway_task or use wait_for_runway_task.',
24
26
  _meta: { 'files/readInputs': { version: 1, inputs: [{ selector: ['reference_images', '*', 'uri'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }] } },
25
27
  inputSchema: z.object({
26
28
  prompt_text: z.string().describe('Text description. Use @tag to reference images (gpt_image_2_6: "the first image", "the second image").'),
27
- model: z.enum(['gen4_image', 'gen4_image_turbo', 'gemini_2.5_flash', 'gemini_image3_pro', 'gpt_image_2_6_sunburst', 'gpt_image_2_6_flare']).optional().describe('Default: gen4_image.'),
28
- ratio: z.enum(IMAGE_RATIOS).optional().describe('Output resolution. Each model takes its own set. Default: 1920:1080 (gemini_image3_pro: 1344:768; gpt_image_2_6: 1920:1088, or auto to let the model choose).'),
29
+ model: z.enum(['gen4_image', 'gen4_image_turbo', 'gemini_2.5_flash', ...RESOLD_IMAGE_MODELS]).optional().describe('Default: gen4_image.'),
30
+ ratio: z.string().optional().describe('Output size as W:H. Each model takes its own set; an unsupported one is refused with the list. Default: 1920:1080 for Runway models; about 16:9 at 1K for the others (gpt_image_2_6: 1920:1088). gpt_image_2_6, ideogram_4_5 and muse_image also take auto; ideogram_4_5 with reference images takes 1024:576 in place of 1280:720 (likewise 576:1024, 1408:704, 704:1408).'),
29
31
  reference_images: z.array(z.object({
30
32
  uri: z.string().describe('HTTPS URL, Runway URI, or local file path.'),
31
33
  tag: z.string().optional().describe('Tag for @mention in prompt. 3-16 lowercase chars.'),
32
- })).min(1).max(16).optional().describe('Optional reference images: 1-3 (gemini_image3_pro up to 14, gpt_image_2_6 up to 16).'),
34
+ })).min(1).max(16).optional().describe('Optional reference images: 1-3 for Runway models; up to 16 for gpt_image_2_6 and minimax_h3_image, 14 for gemini models, 10 for seedream5.5 and muse_image, 5 ideogram_4_5, 3 grok_imagine_image_2, 1 bria_fibo_1_5.'),
33
35
  content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
34
36
  seed: z.number().int().optional().describe('Random seed (0-4294967295).'),
35
37
  }),
@@ -50,7 +52,7 @@ export function registerImageTools(server) {
50
52
  throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${RUNWAY_IMAGE_RATIOS.join(', ')}.`);
51
53
  }
52
54
  const seed = args.seed;
53
- const body = { model, promptText: args.prompt_text, ratio };
55
+ const body = { model, promptText: args.prompt_text, ratio, ...resold?.fields };
54
56
  if (refs && refs.length > 0) {
55
57
  const resolvedRefs = [];
56
58
  for (const [index, r] of refs.entries()) {
@@ -58,9 +60,11 @@ export function registerImageTools(server) {
58
60
  }
59
61
  body.referenceImages = resolvedRefs;
60
62
  }
61
- if (seed !== undefined)
62
- body.seed = seed;
63
- addContentModeration(body, args.content_moderation);
63
+ if (!resold) {
64
+ if (seed !== undefined)
65
+ body.seed = seed;
66
+ addContentModeration(body, args.content_moderation);
67
+ }
64
68
  const result = await runwayFetch('/text_to_image', { method: 'POST', body: JSON.stringify(body) });
65
69
  const is1080p = ['1920:1080', '1080:1920', '1440:1080', '1080:1440'].includes(ratio);
66
70
  const credits = resold ? resold.credits : model === 'gen4_image_turbo' ? 2 : model === 'gemini_2.5_flash' ? 5 : (is1080p ? 8 : 5);
@@ -1,53 +1,60 @@
1
- export declare const RESOLD_VIDEO_MODELS: readonly ["kling_4", "seedance2_5"];
1
+ import { type ResoldFieldSpec } from './resold-specs.generated.js';
2
+ export declare const RESOLD_VIDEO_MODELS: readonly ["kling_4", "kling_4_flash", "seedance2_5", "seedance2_5_flash", "gemini_omni_flash_1.2", "hailuo3", "h3_max", "wan3", "wan3_prime", "grok_imagine_1_5", "grok_imagine_1_5_lite", "happyhorse_1_0"];
2
3
  export type ResoldVideoModel = (typeof RESOLD_VIDEO_MODELS)[number];
3
- type VideoOption = 'audio' | 'seed' | 'negative_prompt' | 'content_moderation';
4
- interface VideoSpec {
5
- label: string;
6
- imageRatios: readonly string[];
7
- textRatios: readonly string[];
8
- defaultImageRatio: string;
9
- defaultTextRatio: string;
10
- minDuration: number;
11
- maxDuration: number;
12
- defaultDuration: number;
13
- options: readonly VideoOption[];
14
- maxPromptChars: number;
15
- creditsPerSecond: (ratio: string) => number;
16
- minimumCredits: number;
17
- }
18
- export declare const VIDEO_SPECS: Record<ResoldVideoModel, VideoSpec>;
4
+ export declare const RESOLD_IMAGE_MODELS: readonly ["gemini_image3_pro", "gpt_image_2_6_sunburst", "gpt_image_2_6_flare", "gemini_image3.1_flash", "gemini_image3.1_flash_lite", "nano_banana_2.1", "seedream5.5", "minimax_h3_image", "ideogram_4_5", "grok_imagine_image_2", "muse_image", "bria_fibo_1_5"];
5
+ export type ResoldImageModel = (typeof RESOLD_IMAGE_MODELS)[number];
19
6
  export declare function isResoldVideoModel(model: string): model is ResoldVideoModel;
7
+ export declare function isResoldImageModel(model: string): model is ResoldImageModel;
8
+ export declare function videoSpec(model: ResoldVideoModel, kind: 'image' | 'text'): ResoldFieldSpec;
9
+ export declare function tierOf(ratio: string, tiers: readonly string[], pixels: Record<string, number>, overrides?: Record<string, string>): string;
10
+ interface VideoPricing {
11
+ /** Sent when the caller gives none, so the estimate matches what Runway bills. */
12
+ image: {
13
+ ratio?: string;
14
+ resolution?: string;
15
+ };
16
+ text: {
17
+ ratio?: string;
18
+ resolution?: string;
19
+ };
20
+ /** Credits per second of output, by tier. */
21
+ rates: Record<string, number>;
22
+ minimum?: number;
23
+ /** Credits for each input frame (first and last). */
24
+ perFrame?: number;
25
+ tierOverrides?: Record<string, string>;
26
+ /** Ratios allowed from an image, where Runway's spec narrows its list in prose. */
27
+ imageRatios?: readonly string[];
28
+ }
29
+ export declare const VIDEO_PRICING: Record<ResoldVideoModel, VideoPricing>;
20
30
  /**
21
- * Check a resold model's prompt, ratio, duration and options, and return the body
22
- * fields to send. Throws INVALID_INPUT, naming the model, for anything its
23
- * spec does not allow, before any request is made.
31
+ * Check a resold model's prompt, ratio, resolution, duration, frames and options,
32
+ * and return the body fields to send (besides model, promptImage and promptText)
33
+ * with the estimated credits. Throws INVALID_INPUT, naming the model, for
34
+ * anything its spec does not allow, before any request is made.
24
35
  */
25
36
  export declare function resoldVideoFields(model: ResoldVideoModel, kind: 'image' | 'text', args: {
26
37
  prompt_text?: string;
27
38
  ratio?: string;
39
+ resolution?: string;
28
40
  duration?: number;
41
+ last_frame_image?: string;
29
42
  audio?: boolean;
30
43
  seed?: number;
31
44
  negative_prompt?: string;
32
45
  content_moderation?: string;
33
46
  }): {
34
- ratio: string;
47
+ fields: Record<string, unknown>;
35
48
  duration: number;
36
- extra: Record<string, unknown>;
37
49
  credits: number;
38
50
  };
39
- export declare const RESOLD_IMAGE_MODELS: readonly ["gemini_image3_pro", "gpt_image_2_6_sunburst", "gpt_image_2_6_flare"];
40
- export type ResoldImageModel = (typeof RESOLD_IMAGE_MODELS)[number];
41
- interface ImageSpec {
42
- ratios: readonly string[];
51
+ interface ImagePricing {
43
52
  defaultRatio: string;
44
- minPromptChars: number;
45
- maxPromptChars: number;
46
- maxReferences: number;
47
- credits: (ratio: string) => number;
53
+ credits: (ratio: string, references: number) => number;
54
+ /** Sizes Runway swaps for others when reference images are given (each listed size is used only in its own mode). */
55
+ withReferences?: Record<string, string>;
48
56
  }
49
- export declare const IMAGE_SPECS: Record<ResoldImageModel, ImageSpec>;
50
- export declare function isResoldImageModel(model: string): model is ResoldImageModel;
57
+ export declare const IMAGE_PRICING: Record<ResoldImageModel, ImagePricing>;
51
58
  /** Check a resold image model's prompt, ratio, references and options; throws INVALID_INPUT naming the model. */
52
59
  export declare function resoldImageFields(model: ResoldImageModel, args: {
53
60
  prompt_text: string;
@@ -59,6 +66,7 @@ export declare function resoldImageFields(model: ResoldImageModel, args: {
59
66
  }>;
60
67
  }): {
61
68
  ratio: string;
69
+ fields: Record<string, unknown>;
62
70
  credits: number;
63
71
  };
64
72
  export {};
@@ -1,178 +1,231 @@
1
1
  import { RunwayError } from '../types.js';
2
+ import { IMAGE_TO_VIDEO, TEXT_TO_VIDEO, TEXT_TO_IMAGE } from './resold-specs.generated.js';
2
3
  // Models Runway resells from other makers. Each one rejects request fields it
3
4
  // does not list (the API's schemas set additionalProperties: false), so the
4
5
  // connector sends a resold model only the fields its own spec allows, and
5
- // refuses any other option with a plain message naming the model. Ratios,
6
- // durations and prices are from Runway's API reference and pricing guide.
7
- export const RESOLD_VIDEO_MODELS = ['kling_4', 'seedance2_5'];
8
- const KLING_4_1080P = new Set(['1920:1080', '1080:1920', '1440:1440', '2200:940', 'auto_1080p']);
9
- const SEEDANCE_TIERS = [
10
- [20, ['992:432', '854:480', '752:560', '640:640', '560:752', '480:854']],
11
- [30, ['1470:630', '1280:720', '1112:834', '960:960', '834:1112', '720:1280']],
12
- [68, ['2206:946', '1920:1080', '1664:1248', '1440:1440', '1248:1664', '1080:1920']],
13
- [110, ['3840:1646', '3840:2160', '3840:2880', '3840:3840', '2880:3840', '2160:3840']],
6
+ // refuses any other option with a plain message naming the model, before any
7
+ // upload or request. The fields and limits come from Runway's published API
8
+ // spec (resold-specs.generated.ts); the defaults and prices below are typed by
9
+ // hand from Runway's pricing guide (docs.dev.runwayml.com/guides/pricing).
10
+ // These models were added from the documentation and never called (FOX-12868),
11
+ // so a mistake here fails for that one model only.
12
+ export const RESOLD_VIDEO_MODELS = [
13
+ 'kling_4', 'kling_4_flash', 'seedance2_5', 'seedance2_5_flash', 'gemini_omni_flash_1.2', 'hailuo3', 'h3_max',
14
+ 'wan3', 'wan3_prime', 'grok_imagine_1_5', 'grok_imagine_1_5_lite', 'happyhorse_1_0',
15
+ ];
16
+ export const RESOLD_IMAGE_MODELS = [
17
+ 'gemini_image3_pro', 'gpt_image_2_6_sunburst', 'gpt_image_2_6_flare', 'gemini_image3.1_flash', 'gemini_image3.1_flash_lite',
18
+ 'nano_banana_2.1', 'seedream5.5', 'minimax_h3_image', 'ideogram_4_5', 'grok_imagine_image_2', 'muse_image', 'bria_fibo_1_5',
14
19
  ];
15
- const SEEDANCE_RATIOS = SEEDANCE_TIERS.flatMap(([, ratios]) => ratios);
16
- export const VIDEO_SPECS = {
17
- kling_4: {
18
- label: 'Kling 4.0',
19
- imageRatios: ['auto_720p', 'auto_1080p'],
20
- textRatios: ['1280:720', '720:1280', '940:940', '1460:624', '1920:1080', '1080:1920', '1440:1440', '2200:940', 'auto_720p', 'auto_1080p'],
21
- defaultImageRatio: 'auto_720p',
22
- defaultTextRatio: '1280:720',
23
- minDuration: 3,
24
- maxDuration: 30,
25
- defaultDuration: 5,
26
- options: [],
27
- maxPromptChars: 26000,
28
- // List price; Runway charges 20% less until 30 Nov 2026.
29
- creditsPerSecond: (ratio) => (KLING_4_1080P.has(ratio) ? 23.5 : 15.7),
30
- minimumCredits: 0,
31
- },
32
- seedance2_5: {
33
- label: 'Seedance 2.5',
34
- imageRatios: SEEDANCE_RATIOS,
35
- textRatios: SEEDANCE_RATIOS,
36
- defaultImageRatio: '1280:720',
37
- defaultTextRatio: '1280:720',
38
- minDuration: 4,
39
- maxDuration: 30,
40
- defaultDuration: 5,
41
- options: ['audio', 'seed'],
42
- maxPromptChars: 15000,
43
- creditsPerSecond: (ratio) => SEEDANCE_TIERS.find(([, ratios]) => ratios.includes(ratio))?.[0] ?? 30,
44
- minimumCredits: 80,
45
- },
46
- };
47
20
  export function isResoldVideoModel(model) {
48
21
  return RESOLD_VIDEO_MODELS.includes(model);
49
22
  }
50
- const SEED_MAX = 4294967295;
51
- function checkPrompt(model, prompt, min, max) {
52
- if (prompt === undefined)
23
+ export function isResoldImageModel(model) {
24
+ return RESOLD_IMAGE_MODELS.includes(model);
25
+ }
26
+ export function videoSpec(model, kind) {
27
+ return (kind === 'image' ? IMAGE_TO_VIDEO : TEXT_TO_VIDEO)[model];
28
+ }
29
+ // ── Price tiers ────────────────────────────────────────────────────────
30
+ // Runway prices a ratio by the resolution it belongs to. A ratio named auto_<tier>
31
+ // is that tier; any other W:H is the tier nearest its pixel count (checked
32
+ // against every listed ratio in resold-models.test.ts), unless overridden.
33
+ const VIDEO_TIER_PIXELS = {
34
+ '360p': 640 * 360, '480p': 854 * 480, '720p': 1280 * 720, '768p': 1366 * 768, '1080p': 1920 * 1080, '2k': 2560 * 1440, '4k': 3840 * 2160,
35
+ };
36
+ const IMAGE_TIER_PIXELS = {
37
+ '512': 512 * 512, '1k': 1024 * 1024, '1.5k': 1536 * 1536, '2k': 2048 * 2048, '4k': 4096 * 4096,
38
+ };
39
+ export function tierOf(ratio, tiers, pixels, overrides = {}) {
40
+ if (overrides[ratio])
41
+ return overrides[ratio];
42
+ if (tiers.length === 1)
43
+ return tiers[0];
44
+ const named = ratio.match(/^auto_(.+)$/)?.[1];
45
+ if (named && tiers.includes(named))
46
+ return named;
47
+ const [w, h] = ratio.split(':').map(Number);
48
+ const distance = (tier) => Math.abs(Math.log((w * h) / pixels[tier]));
49
+ return tiers.reduce((best, tier) => (distance(tier) < distance(best) ? tier : best));
50
+ }
51
+ const WIDE = { image: { ratio: 'auto_720p' }, text: { ratio: '1280:720' } };
52
+ export const VIDEO_PRICING = {
53
+ // List price; Runway charges 20% less until 30 Nov 2026.
54
+ kling_4: { ...WIDE, rates: { '720p': 15.7, '1080p': 23.5 } },
55
+ kling_4_flash: { ...WIDE, rates: { '720p': 9.4 }, minimum: 29 },
56
+ seedance2_5: { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '480p': 20, '720p': 30, '1080p': 68, '4k': 110 }, minimum: 80 },
57
+ seedance2_5_flash: { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '480p': 13, '720p': 20 }, minimum: 52 },
58
+ 'gemini_omni_flash_1.2': { image: { ratio: '1280:720' }, text: { ratio: '1280:720' }, rates: { '360p': 2, '720p': 7, '1080p': 10, '4k': 21 }, minimum: 6, perFrame: 1 },
59
+ hailuo3: { image: { ratio: 'adaptive', resolution: '768p' }, text: { ratio: '16:9', resolution: '768p' }, rates: { '768p': 10, '2k': 15 }, perFrame: 2 },
60
+ h3_max: { image: { resolution: '768p' }, text: { resolution: '768p' }, rates: { '480p': 5, '768p': 8 } },
61
+ // Runway: keyframe image-to-video requests must use an auto_ ratio, which follows the first frame.
62
+ wan3: { ...WIDE, rates: { '480p': 5, '720p': 10, '1080p': 20 }, imageRatios: ['auto_480p', 'auto_720p', 'auto_1080p'] },
63
+ wan3_prime: { ...WIDE, rates: { '480p': 6.8, '720p': 14, '1080p': 28 }, imageRatios: ['auto_480p', 'auto_720p', 'auto_1080p'] },
64
+ grok_imagine_1_5: { image: { resolution: '720p' }, text: { ratio: '16:9', resolution: '720p' }, rates: { '480p': 10, '720p': 16, '1080p': 29 }, perFrame: 1 },
65
+ // Runway lists 720:720 with the 720p sizes.
66
+ grok_imagine_1_5_lite: { ...WIDE, rates: { '480p': 2, '720p': 3, '1080p': 14 }, perFrame: 1, tierOverrides: { '720:720': '720p' } },
67
+ happyhorse_1_0: { image: { resolution: '720p' }, text: { ratio: '1280:720' }, rates: { '720p': 15, '1080p': 30 } },
68
+ };
69
+ const VIDEO_OPTIONS = { audio: 'audio', seed: 'seed', negative_prompt: 'negativePrompt', content_moderation: 'contentModeration' };
70
+ function refuse(message, hint) {
71
+ throw new RunwayError(message, 'INVALID_INPUT', hint);
72
+ }
73
+ function checkPrompt(model, spec, prompt) {
74
+ if (prompt === undefined) {
75
+ if (spec.promptRequired)
76
+ refuse(`${model} needs a prompt here.`, 'Pass prompt_text describing the video or image.');
53
77
  return;
54
- if (prompt.length < min || prompt.length > max) {
55
- throw new RunwayError(`Prompt is ${prompt.length} characters; ${model} takes ${min} to ${max}.`, 'INVALID_INPUT', prompt.length > max ? `Shorten the prompt to ${max} characters or fewer.` : `Write a prompt of at least ${min} characters.`);
78
+ }
79
+ const max = spec.maxPrompt ?? Infinity;
80
+ if (prompt.length < spec.minPrompt || prompt.length > max) {
81
+ refuse(`Prompt is ${prompt.length} characters; ${model} takes ${spec.minPrompt} to ${max}.`, prompt.length > max ? `Shorten the prompt to ${max} characters or fewer.` : `Write a prompt of at least ${spec.minPrompt} characters.`);
82
+ }
83
+ }
84
+ function pick(model, name, given, fallback, allowed) {
85
+ if (allowed.length === 0) {
86
+ if (given !== undefined)
87
+ refuse(`${model} does not take a ${name} here.`, `Leave ${name} out when using ${model}.`);
88
+ return undefined;
89
+ }
90
+ const value = given ?? fallback;
91
+ if (value === undefined || !allowed.includes(value)) {
92
+ refuse(`${model} does not support ${name} ${value} here.`, `Use one of: ${allowed.join(', ')}.`);
93
+ }
94
+ return value;
95
+ }
96
+ function checkSeed(model, spec, seed) {
97
+ const max = spec.seedMax ?? 4294967295;
98
+ if (typeof seed !== 'number' || !Number.isInteger(seed) || seed < 0 || seed > max) {
99
+ refuse(`${model} takes a seed from 0 to ${max}; got ${seed}.`, `Pick a seed from 0 to ${max}, or leave it out.`);
56
100
  }
57
101
  }
58
- const OPTION_BODY_KEYS = {
59
- audio: 'audio',
60
- seed: 'seed',
61
- negative_prompt: 'negativePrompt',
62
- content_moderation: 'contentModeration',
63
- };
64
102
  /**
65
- * Check a resold model's prompt, ratio, duration and options, and return the body
66
- * fields to send. Throws INVALID_INPUT, naming the model, for anything its
67
- * spec does not allow, before any request is made.
103
+ * Check a resold model's prompt, ratio, resolution, duration, frames and options,
104
+ * and return the body fields to send (besides model, promptImage and promptText)
105
+ * with the estimated credits. Throws INVALID_INPUT, naming the model, for
106
+ * anything its spec does not allow, before any request is made.
68
107
  */
69
108
  export function resoldVideoFields(model, kind, args) {
70
- const spec = VIDEO_SPECS[model];
71
- checkPrompt(model, args.prompt_text, 1, spec.maxPromptChars);
72
- const ratios = kind === 'image' ? spec.imageRatios : spec.textRatios;
73
- const ratio = args.ratio ?? (kind === 'image' ? spec.defaultImageRatio : spec.defaultTextRatio);
74
- if (!ratios.includes(ratio)) {
75
- throw new RunwayError(`${model} does not support ratio ${ratio} here.`, 'INVALID_INPUT', `Use one of: ${ratios.join(', ')}.`);
109
+ const spec = videoSpec(model, kind);
110
+ const pricing = VIDEO_PRICING[model];
111
+ const defaults = pricing[kind];
112
+ checkPrompt(model, spec, args.prompt_text);
113
+ if (kind === 'text' && args.ratio === 'adaptive') {
114
+ refuse(`${model} takes ratio adaptive only from an image.`, `Pick a fixed ratio: ${spec.ratios.filter((r) => r !== 'adaptive').join(', ')}.`);
76
115
  }
77
- const duration = args.duration ?? spec.defaultDuration;
78
- if (!Number.isInteger(duration) || duration < spec.minDuration || duration > spec.maxDuration) {
79
- throw new RunwayError(`${model} takes a whole number of seconds from ${spec.minDuration} to ${spec.maxDuration}; got ${duration}.`, 'INVALID_INPUT', `Pick a duration from ${spec.minDuration} to ${spec.maxDuration} seconds.`);
116
+ const ratio = pick(model, 'ratio', args.ratio, defaults.ratio, (kind === 'image' && pricing.imageRatios) || spec.ratios);
117
+ const resolution = pick(model, 'resolution', args.resolution, defaults.resolution, spec.resolutions);
118
+ const duration = args.duration ?? 5;
119
+ const range = spec.duration ?? { min: 5, max: 5 };
120
+ if (!Number.isInteger(duration) || duration < range.min || duration > range.max) {
121
+ refuse(`${model} takes a whole number of seconds from ${range.min} to ${range.max}; got ${duration}.`, `Pick a duration from ${range.min} to ${range.max} seconds.`);
80
122
  }
81
- const extra = {};
82
- for (const option of Object.keys(OPTION_BODY_KEYS)) {
123
+ if (args.last_frame_image !== undefined && !spec.lastFrame) {
124
+ refuse(`${model} takes only a first frame, not a last frame.`, `Leave last_frame_image out when using ${model}.`);
125
+ }
126
+ const fields = { duration };
127
+ if (ratio !== undefined)
128
+ fields.ratio = ratio;
129
+ if (resolution !== undefined)
130
+ fields.resolution = resolution;
131
+ for (const option of Object.keys(VIDEO_OPTIONS)) {
83
132
  const value = args[option];
84
133
  if (value === undefined || (option === 'content_moderation' && value === 'auto'))
85
134
  continue;
86
- if (!spec.options.includes(option)) {
87
- throw new RunwayError(`${model} does not accept ${option}.`, 'INVALID_INPUT', `Leave ${option} out when using ${model}.`);
88
- }
89
- if (option === 'seed' && (typeof value !== 'number' || !Number.isInteger(value) || value < 0 || value > SEED_MAX)) {
90
- throw new RunwayError(`${model} takes a seed from 0 to ${SEED_MAX}; got ${value}.`, 'INVALID_INPUT', `Pick a seed from 0 to ${SEED_MAX}, or leave it out.`);
91
- }
92
- extra[OPTION_BODY_KEYS[option]] = value;
135
+ const key = VIDEO_OPTIONS[option];
136
+ if (!spec.fields.includes(key))
137
+ refuse(`${model} does not accept ${option}.`, `Leave ${option} out when using ${model}.`);
138
+ if (option === 'seed')
139
+ checkSeed(model, spec, value);
140
+ fields[key] = option === 'content_moderation' ? { publicFigureThreshold: value } : value;
93
141
  }
94
- const credits = Math.max(spec.minimumCredits, Math.ceil(spec.creditsPerSecond(ratio) * duration));
95
- return { ratio, duration, extra, credits };
142
+ const tier = resolution ?? tierOf(ratio ?? '', Object.keys(pricing.rates), VIDEO_TIER_PIXELS, pricing.tierOverrides);
143
+ const frames = kind === 'image' ? (args.last_frame_image !== undefined ? 2 : 1) : 0;
144
+ const credits = Math.max(pricing.minimum ?? 0, Math.ceil(pricing.rates[tier] * duration + frames * (pricing.perFrame ?? 0)));
145
+ return { fields, duration, credits };
96
146
  }
97
147
  // ── Images ─────────────────────────────────────────────────────────────
98
- export const RESOLD_IMAGE_MODELS = ['gemini_image3_pro', 'gpt_image_2_6_sunburst', 'gpt_image_2_6_flare'];
99
- const GPT_IMAGE_2_6_RATIOS = [
100
- '2048:880', '1920:1088', '1920:1280', '1920:1440', '1920:1536', '1920:1920', '1536:1920', '1440:1920', '1280:1920', '1088:1920',
101
- '2912:1248', '2560:1440', '2560:1712', '2560:1920', '2560:2048', '2560:2560', '2048:2560', '1920:2560', '1712:2560', '1440:2560',
102
- '3840:1648', '3840:2160', '3504:2336', '3264:2448', '3200:2560', '2880:2880', '2560:3200', '2448:3264', '2336:3504', '2160:3840',
103
- ];
104
- const GEMINI_IMAGE_3_PRO_RATIOS = [
105
- '1344:768', '768:1344', '1024:1024', '1184:864', '864:1184', '1536:672', '832:1248', '1248:832', '896:1152', '1152:896',
106
- '2048:2048', '1696:2528', '2528:1696', '1792:2400', '2400:1792', '1856:2304', '2304:1856', '1536:2752', '2752:1536', '3168:1344',
107
- '4096:4096', '3392:5056', '5056:3392', '3584:4800', '4800:3584', '3712:4608', '4608:3712', '3072:5504', '5504:3072', '6336:2688',
108
- ];
109
148
  // GPT Image 2.6 at the default high quality, by tier and shape (Runway's
110
- // pricing guide). Each tier above lists its ten ratios in this shape order.
149
+ // pricing guide). Each tier lists its ten ratios in this shape order.
111
150
  const GPT_IMAGE_2_6_SHAPES = ['21:9', '16:9', '3:2', '4:3', '5:4', '1:1', '5:4', '4:3', '3:2', '16:9'];
112
151
  const GPT_IMAGE_2_6_HIGH = [
113
152
  { '1:1': 11, '5:4': 8, '4:3': 7, '3:2': 6, '16:9': 5, '21:9': 4 },
114
153
  { '1:1': 16, '5:4': 11, '4:3': 10, '3:2': 8, '16:9': 6, '21:9': 5 },
115
154
  { '1:1': 19, '5:4': 15, '4:3': 14, '3:2': 13, '16:9': 11, '21:9': 7 },
116
155
  ];
117
- // With ratio "auto", Runway charges 19 credits up front at high quality.
118
- const GPT_IMAGE_2_6_AUTO_CREDITS = 19;
119
- function gptImage26Credits(ratio) {
120
- const index = GPT_IMAGE_2_6_RATIOS.indexOf(ratio);
121
- if (index < 0)
122
- return GPT_IMAGE_2_6_AUTO_CREDITS;
123
- return GPT_IMAGE_2_6_HIGH[Math.floor(index / 10)][GPT_IMAGE_2_6_SHAPES[index % 10]];
156
+ function gptImage26Credits(ratio, references) {
157
+ const index = TEXT_TO_IMAGE.gpt_image_2_6_flare.ratios.indexOf(ratio);
158
+ // With ratio "auto", Runway charges 19 credits up front at high quality.
159
+ const perImage = ratio === 'auto' || index < 0 ? 19 : GPT_IMAGE_2_6_HIGH[Math.floor(index / 10)][GPT_IMAGE_2_6_SHAPES[index % 10]];
160
+ return perImage + references;
124
161
  }
125
- const GPT_IMAGE_2_6_SPEC = {
126
- ratios: [...GPT_IMAGE_2_6_RATIOS, 'auto'],
127
- defaultRatio: '1920:1088',
128
- minPromptChars: 1,
129
- maxPromptChars: 32000,
130
- maxReferences: 16,
131
- credits: gptImage26Credits,
132
- };
133
- export const IMAGE_SPECS = {
134
- gemini_image3_pro: {
135
- ratios: GEMINI_IMAGE_3_PRO_RATIOS,
136
- defaultRatio: '1344:768',
137
- minPromptChars: 3,
138
- maxPromptChars: 45000,
139
- maxReferences: 14,
140
- // 20 credits at 1K or 2K, 40 at 4K (the last ten ratios).
141
- credits: (ratio) => (GEMINI_IMAGE_3_PRO_RATIOS.indexOf(ratio) >= 20 ? 40 : 20),
142
- },
162
+ // MiniMax H3 Image at the default (not highspeed): credits by reference count (row) and 1K, 2K, 4K.
163
+ const MINIMAX_H3_IMAGE = [
164
+ [3, 3, 7], [3, 3, 8], [4, 4, 8], [4, 5, 8], [5, 5, 9], [6, 6, 10], [6, 7, 11], [7, 8, 11], [8, 8, 12],
165
+ [9, 9, 13], [9, 10, 14], [10, 11, 14], [11, 12, 15], [12, 12, 16], [12, 13, 17], [13, 14, 18], [14, 15, 18],
166
+ ];
167
+ /** Credits per image by tier, from the ratio's pixel count. */
168
+ const byTier = (table) => (ratio) => table[tierOf(ratio, Object.keys(table), IMAGE_TIER_PIXELS)];
169
+ export const IMAGE_PRICING = {
170
+ gemini_image3_pro: { defaultRatio: '1344:768', credits: byTier({ '1k': 20, '2k': 20, '4k': 40 }) },
143
171
  // Runway lists both 2.6 variants with one description and one price table.
144
- gpt_image_2_6_sunburst: GPT_IMAGE_2_6_SPEC,
145
- gpt_image_2_6_flare: GPT_IMAGE_2_6_SPEC,
172
+ gpt_image_2_6_sunburst: { defaultRatio: '1920:1088', credits: gptImage26Credits },
173
+ gpt_image_2_6_flare: { defaultRatio: '1920:1088', credits: gptImage26Credits },
174
+ 'gemini_image3.1_flash': { defaultRatio: '1344:768', credits: byTier({ '512': 5, '1k': 7, '2k': 11, '4k': 16 }) },
175
+ 'gemini_image3.1_flash_lite': { defaultRatio: '1376:768', credits: () => 4 },
176
+ 'nano_banana_2.1': { defaultRatio: '1376:768', credits: byTier({ '1k': 4, '2k': 6, '4k': 12 }) },
177
+ 'seedream5.5': { defaultRatio: '1424:800', credits: (ratio, refs) => Math.ceil(byTier({ '1k': 2, '1.5k': 2, '2k': 4 })(ratio) + refs * 0.8) },
178
+ minimax_h3_image: { defaultRatio: '1376:768', credits: (ratio, refs) => MINIMAX_H3_IMAGE[refs][['1k', '2k', '4k'].indexOf(tierOf(ratio, ['1k', '2k', '4k'], IMAGE_TIER_PIXELS))] },
179
+ // Runway's default quality: medium with reference images, high without.
180
+ ideogram_4_5: {
181
+ defaultRatio: '1280:720',
182
+ credits: (_ratio, refs) => (refs > 0 ? 8 : 25),
183
+ withReferences: { '1280:720': '1024:576', '720:1280': '576:1024', '1440:720': '1408:704', '720:1440': '704:1408' },
184
+ },
185
+ // Default quality medium; 1 credit per reference image.
186
+ grok_imagine_image_2: { defaultRatio: '1280:720', credits: (ratio, refs) => byTier({ '1k': 6, '2k': 8 })(ratio) + refs },
187
+ muse_image: { defaultRatio: '2016:1152', credits: () => 1 },
188
+ // 1MP and 4MP sizes.
189
+ bria_fibo_1_5: { defaultRatio: '1024:576', credits: byTier({ '1k': 5, '2k': 10 }) },
146
190
  };
147
- export function isResoldImageModel(model) {
148
- return RESOLD_IMAGE_MODELS.includes(model);
149
- }
150
191
  const REFERENCE_TAG = /^[a-z][a-z0-9_]{2,15}$/;
151
192
  /** Check a resold image model's prompt, ratio, references and options; throws INVALID_INPUT naming the model. */
152
193
  export function resoldImageFields(model, args) {
153
- const spec = IMAGE_SPECS[model];
154
- checkPrompt(model, args.prompt_text, spec.minPromptChars, spec.maxPromptChars);
155
- if (args.references.length > spec.maxReferences) {
156
- throw new RunwayError(`${model} takes at most ${spec.maxReferences} reference images; got ${args.references.length}.`, 'INVALID_INPUT', `Pass ${spec.maxReferences} reference images or fewer.`);
194
+ const spec = TEXT_TO_IMAGE[model];
195
+ const pricing = IMAGE_PRICING[model];
196
+ checkPrompt(model, spec, args.prompt_text);
197
+ const max = spec.maxReferences ?? 0;
198
+ if (args.references.length > max) {
199
+ refuse(`${model} takes at most ${max} reference images; got ${args.references.length}.`, `Pass ${max} reference images or fewer.`);
157
200
  }
158
201
  const tags = args.references.flatMap((r) => (r.tag === undefined ? [] : [r.tag]));
202
+ if (tags.length > 0 && !spec.referenceTags) {
203
+ refuse(`${model} does not take reference tags.`, 'Leave the tags out and refer to reference images by order ("the first image").');
204
+ }
159
205
  const badTag = tags.find((tag) => !REFERENCE_TAG.test(tag));
160
206
  if (badTag !== undefined) {
161
- throw new RunwayError(`${model} does not accept the reference tag "${badTag}".`, 'INVALID_INPUT', 'A tag is 3-16 characters: a lowercase letter, then lowercase letters, digits or underscores.');
207
+ refuse(`${model} does not accept the reference tag "${badTag}".`, 'A tag is 3-16 characters: a lowercase letter, then lowercase letters, digits or underscores.');
162
208
  }
163
209
  if (new Set(tags).size !== tags.length) {
164
- throw new RunwayError(`${model} needs a different tag on each reference image.`, 'INVALID_INPUT', 'Give each reference image its own tag, or leave tags out.');
165
- }
166
- const ratio = args.ratio ?? spec.defaultRatio;
167
- if (!spec.ratios.includes(ratio)) {
168
- throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${spec.ratios.join(', ')}.`);
210
+ refuse(`${model} needs a different tag on each reference image.`, 'Give each reference image its own tag, or leave tags out.');
169
211
  }
212
+ const swap = pricing.withReferences ?? {};
213
+ const withRefs = args.references.length > 0;
214
+ const allowed = spec.ratios.filter((r) => !(withRefs ? r in swap : Object.values(swap).includes(r)));
215
+ const fallback = withRefs ? (swap[pricing.defaultRatio] ?? pricing.defaultRatio) : pricing.defaultRatio;
216
+ const ratio = pick(model, 'ratio', args.ratio, fallback, allowed);
217
+ const fields = {};
170
218
  if (args.seed !== undefined) {
171
- throw new RunwayError(`${model} does not accept seed.`, 'INVALID_INPUT', `Leave seed out when using ${model}.`);
219
+ if (!spec.fields.includes('seed'))
220
+ refuse(`${model} does not accept seed.`, `Leave seed out when using ${model}.`);
221
+ checkSeed(model, spec, args.seed);
222
+ fields.seed = args.seed;
172
223
  }
173
224
  if (args.content_moderation !== undefined && args.content_moderation !== 'auto') {
174
- throw new RunwayError(`${model} does not accept content_moderation.`, 'INVALID_INPUT', `Leave content_moderation out when using ${model}.`);
225
+ if (!spec.fields.includes('contentModeration'))
226
+ refuse(`${model} does not accept content_moderation.`, `Leave content_moderation out when using ${model}.`);
227
+ fields.contentModeration = { publicFigureThreshold: args.content_moderation };
175
228
  }
176
- return { ratio, credits: spec.credits(ratio) + (model.startsWith('gpt_image') ? args.references.length : 0) };
229
+ return { ratio, fields, credits: pricing.credits(ratio, args.references.length) };
177
230
  }
178
231
  //# sourceMappingURL=resold-models.js.map
@@ -0,0 +1,24 @@
1
+ export interface ResoldFieldSpec {
2
+ /** Request fields the model accepts, besides model. Anything else is refused by Runway. */
3
+ fields: readonly string[];
4
+ promptRequired: boolean;
5
+ minPrompt: number;
6
+ maxPrompt: number | null;
7
+ /** Allowed ratios; empty when the model takes no ratio here. */
8
+ ratios: readonly string[];
9
+ /** Allowed resolutions, lowercased; empty when the model takes none. */
10
+ resolutions: readonly string[];
11
+ duration?: {
12
+ min: number;
13
+ max: number;
14
+ };
15
+ seedMax?: number;
16
+ /** Image-to-video: whether promptImage may carry a last frame as well as the first. */
17
+ lastFrame?: boolean;
18
+ maxReferences?: number;
19
+ referenceTags?: boolean;
20
+ }
21
+ export declare const IMAGE_TO_VIDEO: Record<string, ResoldFieldSpec>;
22
+ export declare const TEXT_TO_VIDEO: Record<string, ResoldFieldSpec>;
23
+ export declare const TEXT_TO_IMAGE: Record<string, ResoldFieldSpec>;
24
+ //# sourceMappingURL=resold-specs.generated.d.ts.map
@@ -0,0 +1,46 @@
1
+ // Generated by scripts/generate-resold-specs.mjs from Runway's published API spec. Do not edit by hand.
2
+ // Source: https://docs.dev.runwayml.com/openapi.json, version 2024-11-06, sha256 a617495a5ebb91c0bb0d1a4476115d9cd1f3c262100859c00eda15b856465221.
3
+ // The models were read from the documentation, never called (FOX-12868).
4
+ export const IMAGE_TO_VIDEO = {
5
+ "kling_4": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 3, "max": 30 }, "lastFrame": true },
6
+ "kling_4_flash": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["auto_720p"], "resolutions": [], "duration": { "min": 3, "max": 20 }, "lastFrame": false },
7
+ "seedance2_5": { "fields": ["audio", "draft", "duration", "outputFormat", "promptImage", "promptText", "ratio", "referenceAudio", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280", "2206:946", "1920:1080", "1664:1248", "1440:1440", "1248:1664", "1080:1920", "3840:1646", "3840:2160", "3840:2880", "3840:3840", "2880:3840", "2160:3840"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295, "lastFrame": true },
8
+ "seedance2_5_flash": { "fields": ["audio", "duration", "outputFormat", "promptImage", "promptText", "ratio", "referenceAudio", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295, "lastFrame": true },
9
+ "gemini_omni_flash_1.2": { "fields": ["duration", "promptImage", "promptText", "ratio"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["640:360", "360:640", "1280:720", "720:1280", "1920:1080", "1080:1920", "3840:2160", "2160:3840"], "resolutions": [], "duration": { "min": 3, "max": 15 }, "lastFrame": true },
10
+ "hailuo3": { "fields": ["duration", "promptImage", "promptText", "ratio", "referenceAudio", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"], "resolutions": ["768p", "2k"], "duration": { "min": 5, "max": 15 }, "lastFrame": true },
11
+ "h3_max": { "fields": ["duration", "promptExpansionMode", "promptImage", "promptText", "resolution", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": [], "resolutions": ["480p", "768p"], "duration": { "min": 5, "max": 15 }, "seedMax": 4294967295, "lastFrame": true },
12
+ "wan3": { "fields": ["audio", "duration", "promptImage", "promptText", "ratio", "referenceAudio", "referenceVideos"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 }, "lastFrame": true },
13
+ "wan3_prime": { "fields": ["audio", "duration", "promptImage", "promptText", "ratio", "referenceAudio", "referenceVideos"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 }, "lastFrame": true },
14
+ "grok_imagine_1_5": { "fields": ["duration", "promptImage", "promptText", "resolution"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 2500, "ratios": [], "resolutions": ["480p", "720p", "1080p"], "duration": { "min": 1, "max": 15 }, "lastFrame": false },
15
+ "grok_imagine_1_5_lite": { "fields": ["duration", "promptImage", "promptText", "ratio"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 1, "max": 15 }, "lastFrame": false },
16
+ "happyhorse_1_0": { "fields": ["duration", "promptImage", "promptText", "resolution"], "promptRequired": false, "minPrompt": 2, "maxPrompt": 2500, "ratios": [], "resolutions": ["720p", "1080p"], "duration": { "min": 3, "max": 15 }, "lastFrame": false },
17
+ };
18
+ export const TEXT_TO_VIDEO = {
19
+ "kling_4": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["1280:720", "720:1280", "940:940", "1460:624", "1920:1080", "1080:1920", "1440:1440", "2200:940", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 3, "max": 30 } },
20
+ "kling_4_flash": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 26000, "ratios": ["1280:720", "720:1280", "960:960", "1464:628", "auto_720p", "940:940", "1460:624"], "resolutions": [], "duration": { "min": 3, "max": 20 } },
21
+ "seedance2_5": { "fields": ["audio", "draft", "draftTaskId", "duration", "outputFormat", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280", "2206:946", "1920:1080", "1664:1248", "1440:1440", "1248:1664", "1080:1920", "3840:1646", "3840:2160", "3840:2880", "3840:3840", "2880:3840", "2160:3840"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295 },
22
+ "seedance2_5_flash": { "fields": ["audio", "duration", "outputFormat", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "seed"], "promptRequired": false, "minPrompt": 1, "maxPrompt": 15000, "ratios": ["992:432", "854:480", "752:560", "640:640", "560:752", "480:854", "1470:630", "1280:720", "1112:834", "960:960", "834:1112", "720:1280"], "resolutions": [], "duration": { "min": 4, "max": 30 }, "seedMax": 4294967295 },
23
+ "gemini_omni_flash_1.2": { "fields": ["duration", "promptText", "ratio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["640:360", "360:640", "1280:720", "720:1280", "1920:1080", "1080:1920", "3840:2160", "2160:3840"], "resolutions": [], "duration": { "min": 3, "max": 15 } },
24
+ "hailuo3": { "fields": ["duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": ["adaptive", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"], "resolutions": ["768p", "2k"], "duration": { "min": 5, "max": 15 } },
25
+ "h3_max": { "fields": ["duration", "promptExpansionMode", "promptText", "resolution", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 6000, "ratios": [], "resolutions": ["480p", "768p"], "duration": { "min": 5, "max": 15 }, "seedMax": 4294967295 },
26
+ "wan3": { "fields": ["audio", "duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 } },
27
+ "wan3_prime": { "fields": ["audio", "duration", "promptText", "ratio", "referenceAudio", "referenceVideos", "references"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 20000, "ratios": ["832:480", "720:544", "624:624", "544:720", "480:832", "1280:720", "1104:832", "960:960", "832:1104", "720:1280", "1920:1080", "1648:1248", "1440:1440", "1248:1648", "1080:1920", "auto_480p", "auto_720p", "auto_1080p"], "resolutions": [], "duration": { "min": 2, "max": 30 } },
28
+ "grok_imagine_1_5": { "fields": ["duration", "promptText", "ratio", "referenceAudio", "references", "resolution"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"], "resolutions": ["480p", "720p", "1080p"], "duration": { "min": 1, "max": 15 } },
29
+ "grok_imagine_1_5_lite": { "fields": ["duration", "promptText", "ratio"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["848:480", "480:848", "480:480", "640:480", "480:640", "720:480", "480:720", "1280:720", "720:1280", "720:720", "960:720", "720:960", "1088:720", "720:1088", "1904:1072", "1072:1904", "1424:1424", "1648:1232", "1232:1648", "1744:1152", "1152:1744"], "resolutions": [], "duration": { "min": 1, "max": 15 } },
30
+ "happyhorse_1_0": { "fields": ["duration", "promptText", "ratio"], "promptRequired": true, "minPrompt": 2, "maxPrompt": 2500, "ratios": ["1280:720", "720:1280", "960:960", "1108:832", "832:1108", "1920:1080", "1080:1920", "1440:1440", "1662:1248", "1248:1662"], "resolutions": [], "duration": { "min": 3, "max": 15 } },
31
+ };
32
+ export const TEXT_TO_IMAGE = {
33
+ "gemini_image3_pro": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 3, "maxPrompt": 45000, "ratios": ["1344:768", "768:1344", "1024:1024", "1184:864", "864:1184", "1536:672", "832:1248", "1248:832", "896:1152", "1152:896", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
34
+ "gpt_image_2_6_sunburst": { "fields": ["background", "frameCount", "frameDurationMs", "outputCount", "outputFormat", "promptText", "quality", "ratio", "reasoningEffort", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["2048:880", "1920:1088", "1920:1280", "1920:1440", "1920:1536", "1920:1920", "1536:1920", "1440:1920", "1280:1920", "1088:1920", "2912:1248", "2560:1440", "2560:1712", "2560:1920", "2560:2048", "2560:2560", "2048:2560", "1920:2560", "1712:2560", "1440:2560", "3840:1648", "3840:2160", "3504:2336", "3264:2448", "3200:2560", "2880:2880", "2560:3200", "2448:3264", "2336:3504", "2160:3840", "auto"], "resolutions": [], "maxReferences": 16, "referenceTags": true },
35
+ "gpt_image_2_6_flare": { "fields": ["background", "frameCount", "frameDurationMs", "outputCount", "outputFormat", "promptText", "quality", "ratio", "reasoningEffort", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["2048:880", "1920:1088", "1920:1280", "1920:1440", "1920:1536", "1920:1920", "1536:1920", "1440:1920", "1280:1920", "1088:1920", "2912:1248", "2560:1440", "2560:1712", "2560:1920", "2560:2048", "2560:2560", "2048:2560", "1920:2560", "1712:2560", "1440:2560", "3840:1648", "3840:2160", "3504:2336", "3264:2448", "3200:2560", "2880:2880", "2560:3200", "2448:3264", "2336:3504", "2160:3840", "auto"], "resolutions": [], "maxReferences": 16, "referenceTags": true },
36
+ "gemini_image3.1_flash": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["512:512", "416:624", "624:416", "432:592", "592:432", "448:576", "576:448", "384:672", "672:384", "768:336", "256:1024", "1024:256", "176:1408", "1408:176", "1024:1024", "832:1248", "1248:832", "864:1184", "1184:864", "896:1152", "1152:896", "768:1344", "1344:768", "1536:672", "512:2048", "2048:512", "352:2816", "2816:352", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "1024:4096", "4096:1024", "704:5632", "5632:704", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688", "2048:8192", "8192:2048", "1408:11264", "11264:1408"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
37
+ "gemini_image3.1_flash_lite": { "fields": ["outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["1024:1024", "848:1264", "1264:848", "896:1200", "1200:896", "928:1152", "1152:928", "768:1376", "1376:768", "1584:672"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
38
+ "nano_banana_2.1": { "fields": ["outputCount", "promptText", "ratio", "referenceImages", "thinkingLevel"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 45000, "ratios": ["1024:1024", "848:1264", "1264:848", "896:1200", "1200:896", "928:1152", "1152:928", "768:1376", "1376:768", "1584:672", "512:2064", "2064:512", "352:2928", "2928:352", "2048:2048", "1696:2528", "2528:1696", "1792:2400", "2400:1792", "1856:2304", "2304:1856", "1536:2752", "2752:1536", "3168:1344", "1024:4128", "4128:1024", "704:5856", "5856:704", "4096:4096", "3392:5056", "5056:3392", "3584:4800", "4800:3584", "3712:4608", "4608:3712", "3072:5504", "5504:3072", "6336:2688", "2048:8256", "8256:2048", "1408:11712", "11712:1408"], "resolutions": [], "maxReferences": 14, "referenceTags": true },
39
+ "seedream5.5": { "fields": ["background", "outputCount", "outputFormat", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["1024:1024", "1152:864", "864:1152", "1424:800", "800:1424", "1248:832", "832:1248", "1568:672", "1536:1536", "1792:1344", "1344:1792", "2048:1152", "1152:2048", "1872:1248", "1248:1872", "2352:1008", "2048:2048", "2368:1776", "1776:2368", "2816:1584", "1584:2816", "2496:1664", "1664:2496", "3136:1344", "auto_1k", "auto_1.5k", "auto_2k"], "resolutions": [], "maxReferences": 10, "referenceTags": false },
40
+ "minimax_h3_image": { "fields": ["highspeed", "outputCount", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 32000, "ratios": ["1024:1024", "1152:928", "928:1152", "1184:896", "896:1184", "1248:832", "832:1248", "1376:768", "768:1376", "1440:736", "736:1440", "1568:672", "672:1568", "1760:576", "576:1760", "2048:2048", "2304:1824", "1824:2304", "2368:1760", "1760:2368", "2496:1664", "1664:2496", "2720:1536", "1536:2720", "2912:1440", "1440:2912", "3136:1344", "1344:3136", "3552:1184", "1184:3552", "4096:4096", "4576:3648", "3648:4576", "4736:3552", "3552:4736", "5024:3360", "3360:5024", "5472:3072", "3072:5472", "5792:2912", "2912:5792", "6272:2688", "2688:6272", "7104:2368", "2368:7104", "auto_1k", "auto_2k", "auto_4k"], "resolutions": [], "maxReferences": 16, "referenceTags": false },
41
+ "ideogram_4_5": { "fields": ["contextWindow", "maskUri", "outputCount", "preciseEdit", "promptText", "quality", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 10000, "ratios": ["1024:1024", "1280:720", "720:1280", "1152:864", "864:1152", "1248:832", "832:1248", "1120:896", "896:1120", "1440:720", "720:1440", "2048:2048", "2560:1440", "1440:2560", "2304:1728", "1728:2304", "2496:1664", "1664:2496", "2240:1792", "1792:2240", "2880:1440", "1440:2880", "1024:576", "576:1024", "1408:704", "704:1408", "auto"], "resolutions": [], "maxReferences": 5, "referenceTags": false },
42
+ "grok_imagine_image_2": { "fields": ["edit", "outputCount", "promptText", "quality", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 2500, "ratios": ["1024:1024", "1280:720", "720:1280", "1152:864", "864:1152", "1248:832", "832:1248", "1248:576", "576:1248", "1280:576", "576:1280", "1408:704", "704:1408", "2048:2048", "2816:1584", "1584:2816", "2368:1776", "1776:2368", "2496:1664", "1664:2496", "2912:1344", "1344:2912", "3200:1440", "1440:3200", "2912:1456", "1456:2912", "auto_1k", "auto_2k"], "resolutions": [], "maxReferences": 3, "referenceTags": false },
43
+ "muse_image": { "fields": ["outputCount", "outputFormat", "promptText", "ratio", "referenceImages"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 4000, "ratios": ["2352:1008", "2016:1152", "1920:1280", "1792:1344", "1600:1600", "1344:1792", "1280:1920", "1152:2016", "auto"], "resolutions": [], "maxReferences": 10, "referenceTags": false },
44
+ "bria_fibo_1_5": { "fields": ["outputFormat", "promptText", "ratio", "referenceImages", "seed"], "promptRequired": true, "minPrompt": 1, "maxPrompt": 10000, "ratios": ["1024:1024", "768:1152", "1152:768", "768:1024", "1024:768", "768:960", "960:768", "576:1024", "1024:576", "2048:2048", "1536:2304", "2304:1536", "1536:2048", "2048:1536", "1536:1920", "1920:1536", "1152:2048", "2048:1152"], "resolutions": [], "seedMax": 2147483647, "maxReferences": 1, "referenceTags": false },
45
+ };
46
+ //# sourceMappingURL=resold-specs.generated.js.map
@@ -3,34 +3,47 @@ import { z } from 'zod';
3
3
  import { runwayFetch, resolveMediaInput, costEstimate, addContentModeration } from '../client.js';
4
4
  import { RunwayError } from '../types.js';
5
5
  import { withErrorHandling } from '../utils.js';
6
- import { VIDEO_SPECS, isResoldVideoModel, resoldVideoFields } from './resold-models.js';
7
- // Runway's own and Veo models keep the ratios they always took; the tool's
8
- // ratio list also carries the resold models' ratios, so these are checked here.
6
+ import { RESOLD_VIDEO_MODELS, isResoldVideoModel, resoldVideoFields } from './resold-models.js';
7
+ // Runway's own and Veo models keep the ratios they always took; each resold
8
+ // model's ratios are checked against its own spec in resold-models.ts.
9
9
  const RUNWAY_IMAGE_RATIOS = ['1280:720', '720:1280', '960:960', '1104:832', '832:1104', '1584:672'];
10
10
  const RUNWAY_TEXT_RATIOS = ['1280:720', '720:1280'];
11
- const IMAGE_RATIOS = [...new Set([...RUNWAY_IMAGE_RATIOS, ...VIDEO_SPECS.kling_4.imageRatios, ...VIDEO_SPECS.seedance2_5.imageRatios])];
12
- const TEXT_RATIOS = [...new Set([...RUNWAY_TEXT_RATIOS, ...VIDEO_SPECS.kling_4.textRatios, ...VIDEO_SPECS.seedance2_5.textRatios])];
13
- function checkRunwayRatio(model, ratio, allowed) {
11
+ function checkRunwayModel(model, ratio, allowed, resolution) {
14
12
  if (!allowed.includes(ratio)) {
15
13
  throw new RunwayError(`${model} does not support ratio ${ratio}.`, 'INVALID_INPUT', `Use one of: ${allowed.join(', ')}.`);
16
14
  }
15
+ if (resolution !== undefined) {
16
+ throw new RunwayError(`${model} does not take a resolution; its ratio sets the size.`, 'INVALID_INPUT', `Leave resolution out when using ${model}.`);
17
+ }
17
18
  }
19
+ // Shown to the model choosing; every detail is checked in code before any request.
20
+ const RESOLD_VIDEO_GUIDE = 'kling_4 (Kling 4.0, 3-30s, up to 1080p), kling_4_flash (Kling 4.0 Flash, 720p, 3-20s, cheapest Kling), ' +
21
+ 'seedance2_5 (Seedance 2.5, 4-30s, 480p to 4K, audio), seedance2_5_flash (480p/720p, audio), ' +
22
+ 'gemini_omni_flash_1.2 (Google, 3-15s, 360p to 4K, needs a prompt), hailuo3 (MiniMax Hailuo 3, 5-15s, resolution 768p or 2k), ' +
23
+ 'h3_max (MiniMax H3 Max, 5-15s, resolution 480p or 768p, no ratio), wan3 and wan3_prime (Wan 3, 2-30s, 480p to 1080p, audio), ' +
24
+ 'grok_imagine_1_5 (xAI, 1-15s, resolution 480p to 1080p), grok_imagine_1_5_lite (1-15s, cheap), happyhorse_1_0 (3-15s, 720p/1080p). ' +
25
+ 'Models made by others take only their own options; a wrong one is refused with the reason, nothing is charged. ' +
26
+ 'Their prices are estimated from Runway\'s published rates.';
27
+ const RATIO_GUIDE = 'Output size or shape. Runway models default to 1280:720. Models made by others each take their own list ' +
28
+ '(e.g. auto_720p to follow the image, W:H sizes, or shapes like 16:9) and default to a 720p size; an unsupported one is refused with the list.';
29
+ const RESOLUTION_GUIDE = 'Only for hailuo3 (768p, 2k), h3_max (480p, 768p), grok_imagine_1_5 (480p, 720p, 1080p) and happyhorse_1_0 from an image (720p, 1080p). Defaults to 720p or 768p.';
18
30
  export function registerVideoTools(server) {
19
31
  // ── Image-to-Video ────────────────────────────────────────────────────
20
32
  server.registerTool('generate_video_from_image', {
21
33
  description: 'Animate a still image into a video. Supports first-frame (and optionally last-frame) keyframe control. ' +
22
34
  'MODELS: gen4.5 (flagship), gen4_turbo (fast/cheap), veo3.1 (best quality + audio), veo3.1_fast, ' +
23
- 'kling_4 (Kling 4.0, 3-30s; ratio auto_720p or auto_1080p keeps the image framing), seedance2_5 (Seedance 2.5, 4-30s, 480p to 4K, audio). ' +
35
+ RESOLD_VIDEO_GUIDE + ' Last frame: gen4/veo, kling_4, seedance2_5(_flash), gemini_omni_flash_1.2, hailuo3, h3_max, wan3(_prime). ' +
24
36
  'WORKFLOW: Returns task_id → poll with check_runway_task or use wait_for_runway_task.',
25
37
  _meta: { 'files/readInputs': { version: 1, inputs: [{ selector: ['prompt_image'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }, { selector: ['last_frame_image'], base: 'connectorCwd', expandTilde: false, nonLocalPrefixes: ['https://', 'data:', 'runway://'] }] } },
26
38
  inputSchema: z.object({
27
39
  prompt_image: z.string().describe('First frame image. HTTPS URL, Runway URI, or local file path.'),
28
40
  last_frame_image: z.string().optional().describe('Optional last frame image for transition.'),
29
- prompt_text: z.string().optional().describe('Describe the desired motion. kling_4 takes up to 26000 characters, seedance2_5 up to 15000.'),
30
- model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast', 'kling_4', 'seedance2_5']).optional().describe('Default: gen4_turbo.'),
31
- ratio: z.enum(IMAGE_RATIOS).optional().describe('Output resolution. Default: 1280:720 (kling_4: auto_720p). gen4/veo: 1280:720, 720:1280, 960:960, 1104:832, 832:1104, 1584:672. kling_4: auto_720p or auto_1080p. seedance2_5: its listed 480p to 4K ratios.'),
32
- duration: z.number().optional().describe('Seconds. gen4: 2-10 (default 5). veo: 4,6,8 (default 8). kling_4: 3-30, seedance2_5: 4-30 (default 5).'),
33
- audio: z.boolean().optional().describe('Generate audio (veo and seedance2_5 only). Default: true.'),
41
+ prompt_text: z.string().optional().describe('Describe the desired motion. Required for gemini_omni_flash_1.2, hailuo3, h3_max, wan3 and wan3_prime. kling_4 takes up to 26000 characters, wan3 20000, seedance2_5 15000.'),
42
+ model: z.enum(['gen4.5', 'gen4_turbo', 'veo3.1', 'veo3.1_fast', ...RESOLD_VIDEO_MODELS]).optional().describe('Default: gen4_turbo.'),
43
+ ratio: z.string().optional().describe(`${RATIO_GUIDE} gen4/veo: 1280:720, 720:1280, 960:960, 1104:832, 832:1104, 1584:672.`),
44
+ resolution: z.enum(['480p', '720p', '768p', '1080p', '2k']).optional().describe(RESOLUTION_GUIDE),
45
+ duration: z.number().optional().describe('Seconds. gen4: 2-10 (default 5). veo: 4,6,8 (default 8). Models made by others: their own range (default 5).'),
46
+ audio: z.boolean().optional().describe('Generate audio (veo, seedance2_5(_flash), wan3(_prime)). Default: true.'),
34
47
  negative_prompt: z.string().max(1000).optional().describe('What should NOT appear in the output (veo models only, max 1000 chars). Omit to use the default negative prompt.'),
35
48
  content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
36
49
  seed: z.number().int().optional().describe('Random seed (0-4294967295) for reproducibility.'),
@@ -40,11 +53,13 @@ export function registerVideoTools(server) {
40
53
  const reads = fileReadContext(server.server.getClientCapabilities(), extra);
41
54
  const model = args.model || 'gen4_turbo';
42
55
  // Checked before any upload or request, so a wrong option fails for this model only.
43
- const resold = isResoldVideoModel(model) ? resoldVideoFields(model, 'image', { ...args, prompt_text: args.prompt_text || undefined }) : undefined;
56
+ const resold = isResoldVideoModel(model)
57
+ ? resoldVideoFields(model, 'image', { ...args, prompt_text: args.prompt_text || undefined, last_frame_image: args.last_frame_image || undefined })
58
+ : undefined;
44
59
  const isRunwayModel = ['gen4.5', 'gen4_turbo'].includes(model);
45
60
  const ratio = args.ratio || '1280:720';
46
61
  if (!resold)
47
- checkRunwayRatio(model, ratio, RUNWAY_IMAGE_RATIOS);
62
+ checkRunwayModel(model, ratio, RUNWAY_IMAGE_RATIOS, args.resolution);
48
63
  const duration = args.duration || (isRunwayModel ? 5 : 8);
49
64
  const audio = args.audio;
50
65
  const seed = args.seed;
@@ -61,7 +76,7 @@ export function registerVideoTools(server) {
61
76
  promptImage = firstImage;
62
77
  }
63
78
  if (resold) {
64
- const body = { model, promptImage, ratio: resold.ratio, duration: resold.duration, ...resold.extra };
79
+ const body = { model, promptImage, ...resold.fields };
65
80
  if (args.prompt_text)
66
81
  body.promptText = args.prompt_text;
67
82
  const result = await runwayFetch('/image_to_video', { method: 'POST', body: JSON.stringify(body) });
@@ -94,14 +109,15 @@ export function registerVideoTools(server) {
94
109
  // ── Text-to-Video ─────────────────────────────────────────────────────
95
110
  server.registerTool('generate_video_from_text', {
96
111
  description: 'Create a video entirely from a text description. ' +
97
- 'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast, kling_4 (Kling 4.0, 3-30s, up to 1080p), seedance2_5 (Seedance 2.5, 4-30s, 480p to 4K, audio). ' +
112
+ 'MODELS: gen4.5 (flagship), veo3.1 (best + audio), veo3.1_fast, ' + RESOLD_VIDEO_GUIDE + ' ' +
98
113
  'WORKFLOW: Returns task_id → poll or use wait_for_runway_task.',
99
114
  inputSchema: z.object({
100
- prompt_text: z.string().max(26000).describe('Detailed video description. Max 1000 chars (26000 for kling_4, 15000 for seedance2_5).'),
101
- model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast', 'kling_4', 'seedance2_5']).optional().describe('Default: gen4.5.'),
102
- ratio: z.enum(TEXT_RATIOS).optional().describe('Output resolution. Default: 1280:720. gen4.5/veo: 1280:720 or 720:1280. kling_4 and seedance2_5 take more, up to 1080p and 4K.'),
103
- duration: z.number().optional().describe('Seconds. gen4.5: 2-10 (default 5). veo: 4,6,8 (default 8). kling_4: 3-30, seedance2_5: 4-30 (default 5).'),
104
- audio: z.boolean().optional().describe('Generate audio (veo and seedance2_5 only). Default: true.'),
115
+ prompt_text: z.string().max(26000).describe('Detailed video description. Max 1000 chars for gen4.5/veo; models made by others take more (kling_4 26000, wan3 20000, seedance2_5 15000).'),
116
+ model: z.enum(['gen4.5', 'veo3.1', 'veo3.1_fast', ...RESOLD_VIDEO_MODELS]).optional().describe('Default: gen4.5.'),
117
+ ratio: z.string().optional().describe(`${RATIO_GUIDE} gen4.5/veo: 1280:720 or 720:1280.`),
118
+ resolution: z.enum(['480p', '720p', '768p', '1080p', '2k']).optional().describe(RESOLUTION_GUIDE),
119
+ duration: z.number().optional().describe('Seconds. gen4.5: 2-10 (default 5). veo: 4,6,8 (default 8). Models made by others: their own range (default 5).'),
120
+ audio: z.boolean().optional().describe('Generate audio (veo, seedance2_5(_flash), wan3(_prime)). Default: true.'),
105
121
  negative_prompt: z.string().max(1000).optional().describe('What should NOT appear in the output (veo models only, max 1000 chars). Omit to use the default negative prompt.'),
106
122
  content_moderation: z.enum(['auto', 'low']).optional().describe('Public figure threshold.'),
107
123
  seed: z.number().int().optional().describe('Random seed (0-4294967295).'),
@@ -111,7 +127,7 @@ export function registerVideoTools(server) {
111
127
  const model = args.model || 'gen4.5';
112
128
  if (isResoldVideoModel(model)) {
113
129
  const resold = resoldVideoFields(model, 'text', args);
114
- const body = { model, promptText: args.prompt_text, ratio: resold.ratio, duration: resold.duration, ...resold.extra };
130
+ const body = { model, promptText: args.prompt_text, ...resold.fields };
115
131
  const result = await runwayFetch('/text_to_video', { method: 'POST', body: JSON.stringify(body) });
116
132
  return JSON.stringify({
117
133
  ok: true, task_id: result.id, status: 'PENDING', model, duration: resold.duration,
@@ -120,11 +136,11 @@ export function registerVideoTools(server) {
120
136
  });
121
137
  }
122
138
  if (args.prompt_text.length > 1000) {
123
- throw new RunwayError(`Prompt is ${args.prompt_text.length} characters; ${model} supports at most 1000.`, 'INVALID_INPUT', 'Shorten the prompt to 1000 characters, or use kling_4 (up to 26000) or seedance2_5 (up to 15000).');
139
+ throw new RunwayError(`Prompt is ${args.prompt_text.length} characters; ${model} supports at most 1000.`, 'INVALID_INPUT', 'Shorten the prompt to 1000 characters, or use a model that takes more, such as kling_4 (up to 26000) or seedance2_5 (up to 15000).');
124
140
  }
125
141
  const isGen45 = model === 'gen4.5';
126
142
  const ratio = args.ratio || '1280:720';
127
- checkRunwayRatio(model, ratio, RUNWAY_TEXT_RATIOS);
143
+ checkRunwayModel(model, ratio, RUNWAY_TEXT_RATIOS, args.resolution);
128
144
  const duration = args.duration || (isGen45 ? 5 : 8);
129
145
  const audio = args.audio !== false;
130
146
  const seed = args.seed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstone/mcp-server-runway",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "mcpName": "io.github.mindstone/mcp-server-runway",
5
5
  "description": "Runway ML MCP server for Model Context Protocol hosts — AI video, image, audio generation, custom voices, task management",
6
6
  "license": "FSL-1.1-MIT",