Skip to content

MEAI Tools

Shows how to expose Vidu operations as Microsoft.Extensions.AI tools so any IChatClient (OpenAI, Anthropic, etc.) can invoke them as function calls.

This example assumes using Vidu; is in scope and apiKey contains your Vidu API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Use a fake API key - we only exercise the tool builders, not the network.
using var client = new ViduClient(apiKey: "test-key");

// Each helper returns an AIFunction that can be passed into ChatOptions.Tools.
var textToVideo = client.AsTextToVideoTool();
var imageToVideo = client.AsImageToVideoTool();
var referenceToVideo = client.AsReferenceToVideoTool();
var startEndToVideo = client.AsStartEndToVideoTool();
var getTask = client.AsGetTaskCreationsTool();
var upscale = client.AsUpscaleTool();

var tools = new AIFunction[]
{
    textToVideo, imageToVideo, referenceToVideo, startEndToVideo, getTask, upscale,
};