Text to Image

Text to Image UI

AI Server's Text to Image UI lets send Text to Image requests to any of its active Comfy UI Agents Models, Diffusion or DALLĀ·E 3 API Providers:

https://localhost:5006/TextToImage

Using Text to Image Endpoints

These endpoints are used in a similar way to other AI Server endpoints where you can provide:

  • RefId - provide a unique identifier to track requests
  • Tag - categorize like requests under a common group

In addition Queue requests can provide:

  • ReplyTo - URL to send a POST request to when the request is complete

Text to Image

var response = client.Post(new TextToImage
{
    Height = 768,
    Width = 768,
    Model = "sdxl-lightning",
    PositivePrompt = "A happy llama",
    NegativePrompt = "bad quality, blurry image"
});
File.WriteAllBytes(saveToPath, response.Results[0].Url.GetBytesFromUrl());

Queue Text to Image

var response = client.Post(new QueueTextToImage
{
    Height = 768,
    Width = 768,
    Model = "sdxl-lightning",
    PositivePrompt = "A happy llama",
    NegativePrompt = "bad quality, blurry image"
});

// Poll for Job Completion Status
GetArtifactGenerationStatusResponse status = new();
while (status.JobState is BackgroundJobState.Queued or BackgroundJobState.Started)
{
    status = client.Get(new GetArtifactGenerationStatus { JobId = response.JobId });
    Thread.Sleep(1000);
}
if (status.Results?.Count > 0)
{
    File.WriteAllBytes(saveToPath, status.Results[0].Url.GetBytesFromUrl());
}