Skip to content

CsmAi

Modern .NET SDK for CsmAi generated from the provider's OpenAPI definition with AutoSDK.

Nuget package dotnet License: MIT Discord

Generated from the source spec

Built from a manually authored OpenAPI definition cross-referenced against docs.csm.ai and the official Python SDK.

Auto-updated

Designed for fast regeneration and low-friction updates when the upstream API changes without breaking compatibility.

Modern .NET

Targets current .NET practices including nullability, trimming, NativeAOT awareness, and source-generated serialization.

Docs from examples

Examples stay in sync between the README, MkDocs site, and integration tests through the AutoSDK docs pipeline.

Usage

1
2
3
using CsmAi;

using var client = new CsmAiClient(apiKey);

Image to 3D

Shows how to start an image-to-3D session using the legacy endpoint used by the official Python SDK, then poll for its status.

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

// Kick off an image-to-3D session from a public image URL.
var envelope = await client.ImageTo3d.CreateImageTo3DSessionAsync(
    new LegacyImageTo3DRequest
    {
        ImageUrl = "https://via.placeholder.com/300/09f/fff.png",
        GeometryModel = GeometryModel.Turbo,
        TextureModel = TextureModel.Pbr,
    });
Console.WriteLine($"Session Code: {envelope.Data.SessionCode}");

// Retrieve current status once.
var status = await client.ImageTo3d.GetImageTo3DSessionAsync(envelope.Data.SessionCode!);
Console.WriteLine($"Status: {status.Data!.SessionStatus}, Progress: {status.Data.PercentDone}%");

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.

 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}");

Create a Scene session (v3)

Shows how to use the unified v3 Sessions API to create a full 3D scene generation — CSM's headline capability distinguishing it from single-object generators.

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

// Create a scene session using the unified v3 Sessions API.
var session = await client.Sessions.CreateSessionAsync(
    new CreateSessionRequest
    {
        Type = SessionType.Scene,
        Input = new SessionInput
        {
            Prompt = "a cozy medieval village at sunset with cobblestone streets",
        },
    });

Console.WriteLine($"Scene session id: {session.Id ?? session.SessionCode}");

List sessions

Shows how to list recent sessions (user's 3D assets) via the unified v3 API.

1
2
3
4
5
using var client = new CsmAiClient(apiKey);

// List up to 5 recent sessions for the current user.
var result = await client.Sessions.ListSessionsAsync(limit: 5);
Console.WriteLine($"Returned {result.Results?.Count ?? 0} sessions (total={result.Total}).");

Support

Bugs

Open an issue in tryAGI/CsmAi.

Ideas and questions

Use GitHub Discussions for design questions and usage help.

Community

Join the tryAGI Discord for broader discussion across SDKs.

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.