Skip to main content
Glama

generate_video

Create videos from text prompts using AI models, returning a URL to the generated content with customizable aspect ratio and duration.

Instructions

Generate a video using Pollinations API. Returns a URL to the generated video.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesText prompt for video generation
modelNoModel ID (default: grok-video)grok-video
aspect_ratioNoAspect ratio1:1
durationNoDuration in seconds (model-dependent)
seedNoSeed for reproducibility

Implementation Reference

  • Handler for the 'generate_video' tool, constructing the request URL for the Pollinations API.
    export async function handleGenerateVideo(
      args: z.infer<typeof generateVideoSchema>
    ) {
      const model = getModel(args.model);
      if (!model || model.type !== "video") {
        return {
          content: [
            {
              type: "text" as const,
              text: `Unknown video model: ${args.model}. Use list_models to see available models.`,
            },
          ],
          isError: true,
        };
      }
      if (!model.free && !API_KEY) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Model "${args.model}" requires a Pollinations API key. Set POLLINATIONS_API_KEY env variable.`,
            },
          ],
          isError: true,
        };
      }
    
      const params = new URLSearchParams({
        model: args.model,
        aspectRatio: args.aspect_ratio,
        nologo: "true",
      });
      if (args.duration !== undefined) params.set("duration", String(args.duration));
      if (args.seed !== undefined) params.set("seed", String(args.seed));
      if (API_KEY) params.set("token", API_KEY);
    
      const encodedPrompt = encodeURIComponent(args.prompt);
      const url = `https://gen.pollinations.ai/video/${encodedPrompt}?${params}`;
    
      return {
        content: [
          {
            type: "text" as const,
            text: [
              `Video generation started!`,
              `Model: ${model.name}`,
              `Aspect ratio: ${args.aspect_ratio}`,
              `URL: ${url}`,
              `Note: Video generation may take 30-120 seconds. Open the URL in a browser to download.`,
            ].join("\n"),
          },
        ],
      };
    }
  • Zod schema definition for 'generate_video' input parameters.
    export const generateVideoSchema = z.object({
      prompt: z.string().describe("Text prompt for video generation"),
      model: z.string().default("grok-video").describe("Model ID (default: grok-video)"),
      aspect_ratio: z
        .enum(["1:1", "16:9", "9:16"])
        .default("1:1")
        .describe("Aspect ratio"),
      duration: z.number().optional().describe("Duration in seconds (model-dependent)"),
      seed: z.number().optional().describe("Seed for reproducibility"),
    });

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/doctorm333/promptpilot-mcp-server'

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