Skip to content

Image Generation

Example showing how to generate images with Photosonic.

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

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

// Generate an image from a text description:
var response = await client.GenerateImageAsync(
    request: new GenerateImageRequest
    {
        Prompt = "A futuristic city skyline at sunset with flying cars",
        NumImages = 1,
        ImageWidth = 512,
        ImageHeight = 512,
    });