Skip to content

Text to 3D (text-to-image stage)

Shows how to start a text-to-image session — the first stage of CSM's text-to-3D pipeline. The returned image is then piped into an image-to-3D session.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using var client = new CsmAiClient(apiKey);

// Create a text-to-image session (first stage of the text-to-3D pipeline).
var response = await client.TextToImage.CreateTextToImageSessionAsync(
    new LegacyTextToImageRequest
    {
        Prompt = "a wooden treasure chest, front view, clean background",
        StyleId = string.Empty,
        Guidance = "6",
    });
Console.WriteLine($"Session Code: {response.Data.SessionCode}");

// Fetch the session once.
var status = await client.TextToImage.GetTextToImageSessionAsync(response.Data.SessionCode!);
Console.WriteLine($"Status: {status.Data!.Status}");