One Logo Pool Ball
ImagePlayground · IOS API REFERENCE

ImageCreator

class · iOS 18.4+ · Deprecated in iOS 27.0 · SDK 27.1

final class ImageCreator

Generates images programmatically from the description and style information you specify. Use an `ImageCreator` object to generate images programmatically from your app on devices that support the capability. You provide a description of the image content, as a text string or as a combination of text and images. The system’s generative models use that information to generate one or more images and return them to your code. Create an `ImageCreator` object and use its ``images(for:style:limit:)`` method to start the image generation process. Image generation occurs asynchronously, delivering results back to your code using an <doc://com.apple.documentation/documentation/swift/asyncsequence> object.

Members (4)

get · iOS 18.4+ · Deprecated in iOS 27.0

availableStyles

TypeScript
get availableStyles(): Array<ImagePlaygroundStyle>
Swift declaration
final let availableStyles: [ImagePlaygroundStyle]

The set of styles you can apply to the images you create. Before requesting any images, make sure the style you want to use is in this property.

method · iOS 18.4+ · Deprecated in iOS 27.0

images

TypeScript
imagesForStyleLimit(concepts: Array<ImagePlaygroundConcept>, style: ImagePlaygroundStyle, limit: number): SDKHandle
Swift declaration
final func images(for concepts: [ImagePlaygroundConcept], style: ImagePlaygroundStyle, limit: Int) -> some AsyncSequence<ImageCreator.CreatedImage, any Error>

Starts the creation of images based on the description and style information you provide. - Parameters: - style: The style you want the model to apply to the output image. It is a programmer error to specify a style that’s not in the `availableStyles` property. - concepts: The elements that describe the expected contents of the image. - limit: The maximum number of images you want the system to create. The system limits the maximum number of images to 4. - Returns: An asynchronous stream you use to receive the images. Call this method to start the image generation process with the specified parameters. The method executes asynchronously and returns the images on the provided <doc://com.apple.documentation/documentation/swift/asyncsequence> object. The following example configures an image creator, starts the creation of the images, and processes the generated images as they arrive. ```swift do { let creator = try await ImageCreator() guard let style = creator.availableStyles.first else { return } let images = creator.images( for: [.text("A cat wearing mittens.")] style: style, limit: 4) // Receive the images. for try await image in images { let anImage = image.cgImage // Do something with the image. } } catch ImageCreator.Error.notSupported { print(“Image creation not supported on the current device.”) } ```

method · iOS 26.4+ · Deprecated in iOS 27.0

images

TypeScript
imagesForStyleOptionsLimit(concepts: Array<ImagePlaygroundConcept>, style: ImagePlaygroundStyle, options: ImagePlaygroundOptions, limit: number): SDKHandle
Swift declaration
final func images(for concepts: [ImagePlaygroundConcept], style: ImagePlaygroundStyle, options: ImagePlaygroundOptions, limit: Int) -> some AsyncSequence<ImageCreator.CreatedImage, any Error>

Creates one or more images from the provided description and style information and returns the results asynchronously. - Parameters: - style: The style you want the model to apply to the output image. It is a programmer error to specify a style that’s not in the `availableStyles` property. - concepts: An array of initial concepts (text descriptions, concepts extracted from text, drawings) that describe the expected contents of the returned images. - options: Options that influence the image creation behavior. - limit: The maximum number of images you want the system to create. The system limits the maximum number of images to 4. - Returns: An asynchronous stream you use to receive the images. Call this method to start the image generation process with the specified parameters. The method runs asynchronously and returns the results using the provided <doc://com.apple.documentation/documentation/swift/asyncsequence> object. The following example configures an image creator, starts the creation of the images, and processes the generated images as they arrive: ```swift do { let creator = try await ImageCreator() guard let style = creator.availableStyles.first else { return } var options = ImagePlaygroundOptions() options.creationVariety = .high options.personalization = .enabled options.sizeSpecification = ImagePlaygroundOptions.SizeSpecification.closest(to: CGSize(width: 1024.0, height: 1024.0)) let images = creator.images( for: [.text("A cat wearing mittens.")] style: style, options: options, limit: 4) // Receive the images. for try await image in images { let anImage = image.cgImage // Do something with the image. } } catch ImageCreator.Error.notSupported { print(“Image creation not supported on the current device.”) } ```

init · iOS 18.4+ · Deprecated in iOS 27.0

init

TypeScript
static init(): Promise<ImageCreator>
Swift declaration
init() async throws

Creates a new image creator object for you to use in your app. If the device doesn’t support image creation or the feature is currently unavailable, this initializer throws an error. - Throws: `ImageCreator.Error.notSupported` on iOS 27.0+, macOS 27.0+, and visionOS 27.0+.

Skipped declarations

No declarations were skipped in this snapshot.

All ImagePlayground types →