stability 0.0.2+1 copy "stability: ^0.0.2+1" to clipboard
stability: ^0.0.2+1 copied to clipboard

Stability AI dart package. Includes all the necessary tools to work with the Stability AI API. All endpoints implemented.

Stability AI API client #

This package prepared by using the documentation.

All endpoints are implemented.

Available Endpoints #

Group Endpoint Status
Engines
List Engines ☑️
User
Account ☑️
Balance ☑️
SDXL & SD1.6
Text to Image
Image to Image with Prompt ☑️
Image to Image with Mask ☑️
Image to Image upscale ☑️
3D
Stable Fast 3D ☑️
Video
Start Generation ☑️
Fetch Generation Result ☑️
Stable Image - Generate
Ultra ☑️
Core ☑️
Diffusion 3 - text2image
Diffusion 3 - image2image ☑️
Stable Image - Upscale
Conservative ☑️
Start Upscale ☑️
Fetch Upscale Result ☑️
Stable Image - Edit
Erase ☑️
Inpaint ☑️
Outpaint ☑️
Search & Replace ☑️
Remove Background ☑️
Stable Image - Control
Sketch ☑️
Structure ☑️
Style ☑️
  • ❌ : not finished
  • ☑️ : Not Tested
  • ✅ : finished

Example:


import 'package:stability/stability.dart';

void main() async {
 final stability = Stability(apiKey: "YOUR_API_KEY");
 // or
 final stability = Stability(); // apiKey will be read from STABILITY_API_KEY environment variable or --stability-api-key argument

 final engines = await stability.engines.list();

 print(engines);

 final FileHandler file = stability.image.generate.diffusion3Image2Image(
     image: FileFrom.path("path/to/image.jpg"),
     strength: 0.5
 );

 await file.writeToFile("path/to/output.jpg");
 // or
 final Uint8List bytes = await file.readAsBytes();

 final (seed, finishReason) = await file.readHeaders();

 print(seed);
}

Providing Files #

Anywhere a file is required, you can provide it in the following ways:

doIt() {
  FileFrom.path("path/to/file.jpg");

  FileFrom.bytes(Uint8List.fromList([1, 2, 3]));

  FileFrom.base64("base64encodedstring");
}

Handling Files #

Anywhere a file is returned, you can handle it in the following ways:

If the endpoint returns single file:


doIt() async {
  final FileHandler file = stability.image.generate.diffusion3Image2Image(
      image: FileFrom.path("path/to/image.jpg"),
      strength: 0.5
  );


  await file.writeToFile("path/to/output.jpg");

// or

  final Uint8List bytes = await file.readAsBytes();
}

If the endpoint returns multiple files:

doIt() async {
  final res = await stability.sdxlV1.textToImage();

  final Base64File file1 = res.files[0];

  await file1.writeToFile("path/to/output1.jpg");

  final bytes = file1.readAsBytes();
}

Handling Errors #

doIt() async {
  try {
    final res = await stability.sdxlV1.textToImage();
  } on StabilityError catch (e) {
    print(e.status); // 404
    print(e.statusText); // Not Found
    print(e.body); // {"foo": "bar"}  
  }
}

That's it! You're ready to use the Stability AI API client.

NOTE: This package is not an official package of Stability AI. It is created by Mehmet Yaz. #

Support #

"Buy Me A Coffee"

0
likes
160
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

Stability AI dart package. Includes all the necessary tools to work with the Stability AI API. All endpoints implemented.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

http, http_parser

More

Packages that depend on stability