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
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Text prompt for video generation | |
| model | No | Model ID (default: grok-video) | grok-video |
| aspect_ratio | No | Aspect ratio | 1:1 |
| duration | No | Duration in seconds (model-dependent) | |
| seed | No | Seed for reproducibility |
Implementation Reference
- src/tools.ts:215-268 (handler)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"), }, ], }; } - src/tools.ts:66-75 (schema)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"), });