openai-async-image-swiftui

1.0.0

OpenAI swift async text to image for SwiftUI app using open ai api Just type in a text description, diffusion model, swift image chatgpt generator chat gpt asyncimage swiftui
The-Igor/openai-async-image-swiftui

What's New

OpenAI DALL·E AsyncImage SwiftUI

2023-03-03T03:04:11Z

Features

  • Multiplatform iOS, macOS, watchOS and tvOS
  • Customizable in term of SwiftUI Image specs [renderingMode, resizable, antialiased...]
  • Customizable in term of the transport layer [Loader]
  • Based on interfaces not implementations

OpenAI AsyncImage SwiftUI

SwiftUI view that asynchronously loads and displays an OpenAI image from open API You just type in any your idea and AI will give you an art solution

Features

  • Multiplatform iOS, macOS, watchOS and tvOS
  • Customizable in term of SwiftUI Image specs [renderingMode, resizable, antialiased...]
  • Customizable in term of the transport layer [Loader]
  • Based on interfaces not implementations

OpenAI AsyncImage SwiftUI

How to use

1. Get your API key from OpenAI

Where do I find my Secret API Key?

2. Override the default loader at Environment with you apiKey

    let apiKey = "your API KEY"
    let endpoint = OpenAIImageEndpoint.get(with: apiKey)
    let loader = OpenAIDefaultLoader(endpoint: endpoint)
    OpenAIDefaultLoaderKey.defaultValue = loader

3. Add OpenAIAsyncImage to your code

OpenAIAsyncImage(prompt: .constant("sun"))
               .frame(width: 125, height: 125)

or with custom ViewBuilder

OpenAIAsyncImage(prompt: $imageText, size: .dpi1024){ state in
    switch state{
        case .loaded(let image) :
        image
            .resizable()
            .scaledToFill()
        case .loadError(let error) : Text(error.localizedDescription)
        case .loading : ProgressView()
    }
}
Param Description
prompt A text description of the desired image(s). The maximum length is 1000 characters
size The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024
tpl Custom view builder tpl
loader Custom loader if you need something specific

OpenAI AsyncImage SwiftUI

Documentation(API)

  • You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
  • Go to Product > Build Documentation or ⌃⇧⌘ D

SwiftUI example for the package

OpenAI AsyncImage SwiftUI example

OpenAI AsyncImage SwiftUI

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Fri May 03 2024 03:14:18 GMT-0900 (Hawaii-Aleutian Daylight Time)