runway_generateImage
Generate images from text prompts using AI, with optional reference images for precise control over visual elements and multiple aspect ratio options.
Instructions
Generate an image from a text prompt and optional reference images. Available ratios are 1920:1080, 1080:1920, 1024:1024, 1360:768, 1080:1080, 1168:880, 1440:1080, 1080:1440, 1808:768, 2112:912, 1280:720, 720:1280, 720:720, 960:720, 720:960, 1680:720. Use 1920:1080 by default. It also accepts reference images, in the form of either a url or a base64 encoded image. Each reference image has a tag, which is a string that refers to the image from the user prompt. For example, if the user prompt is "IMG_1 on a red background", and the reference image has the tag "IMG_1", the model will use that reference image to generate the image. The return of this function will contain a url to the generated image.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| promptText | Yes | ||
| ratio | Yes | ||
| referenceImages | No |
Input Schema (JSON Schema)
Implementation Reference
- src/index.ts:114-137 (handler)The asynchronous handler function for the runway_generateImage tool. It invokes the Runway /text_to_image API endpoint asynchronously, waits for task completion, and returns a success message with the image URL or the task details.async ({ promptText, ratio, referenceImages }) => { const task = await callRunwayAsync("/text_to_image", { method: "POST", body: JSON.stringify({ model: "gen4_image", promptText, ratio, referenceImages, }), }); if (task.status === "SUCCEEDED") { return { content: [ { type: "text", text: `Here is the URL of the image: ${task.output[0]}. Return to the user, as a markdown link, the URL of the image and the prompt that was used to generate the image.`, }, ], }; } else { return { content: [{ type: "text", text: JSON.stringify(task) }] }; } }
- src/index.ts:107-113 (schema)Zod input schema for the tool: required promptText and ratio (strings), optional referenceImages (array of {uri: string, tag?: string}).{ promptText: z.string(), ratio: z.string(), referenceImages: z .array(z.object({ uri: z.string(), tag: z.string().optional() })) .optional(), },
- src/index.ts:100-138 (registration)Full registration of the 'runway_generateImage' tool via server.tool(), including the tool name, multi-line description, input schema, and inline handler function.server.tool( "runway_generateImage", `Generate an image from a text prompt and optional reference images. Available ratios are 1920:1080, 1080:1920, 1024:1024, 1360:768, 1080:1080, 1168:880, 1440:1080, 1080:1440, 1808:768, 2112:912, 1280:720, 720:1280, 720:720, 960:720, 720:960, 1680:720. Use 1920:1080 by default. It also accepts reference images, in the form of either a url or a base64 encoded image. Each reference image has a tag, which is a string that refers to the image from the user prompt. For example, if the user prompt is "IMG_1 on a red background", and the reference image has the tag "IMG_1", the model will use that reference image to generate the image. The return of this function will contain a url to the generated image.`, { promptText: z.string(), ratio: z.string(), referenceImages: z .array(z.object({ uri: z.string(), tag: z.string().optional() })) .optional(), }, async ({ promptText, ratio, referenceImages }) => { const task = await callRunwayAsync("/text_to_image", { method: "POST", body: JSON.stringify({ model: "gen4_image", promptText, ratio, referenceImages, }), }); if (task.status === "SUCCEEDED") { return { content: [ { type: "text", text: `Here is the URL of the image: ${task.output[0]}. Return to the user, as a markdown link, the URL of the image and the prompt that was used to generate the image.`, }, ], }; } else { return { content: [{ type: "text", text: JSON.stringify(task) }] }; } } );