Skip to content

Text-to-Video

Basic example showing how to create a text-to-video project.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Create an authenticated client using your API key.
using var client = new MagicHourClient(apiKey);

// Create a text-to-video generation job with a prompt.
var response = await client.VideoProjects.TextToVideoCreateVideoAsync(
    request: new TextToVideoCreateVideoRequest
    {
        EndSeconds = 5,
        AspectRatio = TextToVideoCreateVideoRequestAspectRatio.x16_9,
        Resolution = TextToVideoCreateVideoRequestResolution.x720p,
        Model = TextToVideoCreateVideoRequestModel.Default,
        Style = new TextToVideoCreateVideoRequestStyle
        {
            Prompt = "a dog running through a meadow",
        },
    });

// The response contains the project ID and estimated credits charged.

// Poll for completion using the video project status endpoint.
var status = await client.VideoProjects.VideoProjectsGetDetailsAsync(
    id: response.Id);