Skip to content

Stability.ai API implementation for Swift enables seamless integration of stability analysis and prediction capabilities into your Swift-based applications.

License

Notifications You must be signed in to change notification settings

ftp27/stabilityai-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stability.ai KIT

Stability.ai KIT implementation for Swift enables seamless integration of stability analysis and prediction capabilities into your Swift-based applications.

Available Features

Installation

You can install the Stability.ai KIT package using Swift Package Manager. Add the following dependency to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/ftp27/stabilityai-kit", from: "1.0.0")
]

Usage

Documentation

The framework is fully documented using Xcode's documentation system. You can also find the documentation online at appledoc.

Configuration

To use the framework, first create a Configuration instance with the necessary API key and optional client information:

let configuration = Configuration(apiKey: "YOUR_API_KEY")

You can also customize the clientId, clientVersion, organization properties of the configuration if needed.

Proxy support

If you need to use a proxy to connect to the Stability AI API, you can set the api property of the configuration:

let configuration = Configuration(
    apiKey: "YOUR_API_KEY",
    api: .init(
        scheme: .https,
        host: "proxyhost.com"
    )
)

Creating a Client

Once you have a configuration, create a Client instance:

let client = Client(configuration: configuration)

Making API Requests

The framework provides methods to interact with the Stability AI API. Here are some example requests:

Get Account Information

do {
    let account = try await client.getAccount()
    // Use the account information
} catch {
    // Handle error
}

Get Balance Information

do {
    let balance = try await client.getBalance()
    // Use the balance information
} catch {
    // Handle error
}

Get Engines

do {
    let engines = try await client.getEngines()
    // Use the list of engines
} catch {
    // Handle error
}

Text to Image Conversion

let request = TextToImageRequest(textPrompts: [.init(text: "your prompt")])

do {
    let results = try await client.getImageFromText(request, engine: "ENGINE_ID")
    // Use the resulting images
} catch {
    // Handle error
}

Image to Image Conversion

let request = ImageToImageRequest
    .strength(
        textPrompts: [.init(text: "your prompt")]),
        initImage: image.pngData()!,
        strength: 0.5
    )
    .setStylePreset(.cinematic) // Optional
    .setSteps(40) // Optional

do {
    let results = try await client.getImageFromImage(request, engine: "ENGINE_ID")
    // Use the resulting images
} catch {
    // Handle error
}

Contributing

Contributions are welcomed to the framework. If you have a feature request, bug report, or patch, please feel free to open an issue or pull request.

License

This Swift package is licensed under the MIT License. See the LICENSE file for more information.

About

Stability.ai API implementation for Swift enables seamless integration of stability analysis and prediction capabilities into your Swift-based applications.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages