Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
promptTextYes
ratioYes
referenceImagesNo

Implementation Reference

  • 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) }] };
      }
    }
  • 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) }] };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/runwayml/runway-api-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server