Request text-to-video generation based on the given user prompt. After requesting the video, use the waitForVideo tool to wait for completion and get the resulting video. The status will be “success” and the task ID will be returned.
Wait for a previously requested video to be generated and return the video URL. When the video generation is complete, the status will be “success” and the video URL will be returned. If the video is not generated within the timeout, it will return an error.
Create a reusable service configuration that points to the MCP server and standardizes how you pass arguments and read results. This lets your agent easily interact with the Video tools in a consistent manner.
Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
Copy
Ask AI
// Import the ATXP client SDKimport { atxpClient, ATXPAccount } from '@atxp/client';// Read the ATXP account details from environment variablesconst atxpConnectionString = process.env.ATXP_CONNECTION;// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: imageService.mcpServer, account: new ATXPAccount(atxpConnectionString),});
3
Use the Video service in your agent
Call the Video tool by passing your natural-language instruction as the argument the getArguments method.Read the response using the getResult method.
Copy
Ask AI
const prompt = "Create a video of a cat riding a horse. Use a realistic style.";try { const result = await client.callTool({ name: videoService.createVideoToolName, arguments: videoService.getCreateVideoArguments(prompt), }); const createVideoResult = videoService.getCreateVideoResult(result); console.log('Status:', createVideoResult.status); console.log('Task ID:', createVideoResult.taskId); const pollInterval = 15000; // 15 seconds while (true) { const result = await client.callTool({ name: videoService.waitForVideoToolName, arguments: videoService.getWaitForVideoArguments(createVideoResult.taskId), }); const waitForVideoResult = videoService.getWaitForVideoResult(result); console.log('Status:', waitForVideoResult.status); console.log('URL:', waitForVideoResult.url); // Check if task is complete if (waitForVideoResult.status === 'success') { console.log(`${videoService.description} has generated a video!`); console.log('URL:', waitForVideoResult.url); break; } // Wait before next poll console.log(`${videoService.description} result pending.`); await new Promise(resolve => setTimeout(resolve, pollInterval)); }} catch (error) { console.error(`Error with ${videoService.description}:`, error); process.exit(1);}
You should see the result of the video creation printed in your console.