This example assumes using Leonardo; is in scope and apiKey contains your Leonardo API key.
1 2 3 4 5 6 7 8 910
usingvarapi=GetAuthorizedClient();varcreateResponse=awaitapi.Image.CreateGenerationAsync(prompt:"Generate cat");awaitTask.Delay(TimeSpan.FromSeconds(15));varresponse=awaitapi.Image.GetGenerationByIdAsync(createResponse.SdGenerationJob?.GenerationId??thrownewInvalidOperationException("GenerationId is null"));varurl=response.GenerationsByPk?.GeneratedImages?.ElementAtOrDefault(0)?.Url;