stability library
Stability AI API client
This package prepared by using the documentation. Some limitations may apply. Please check the documentation for more information.
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 = await 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);
}
When an API call fails, a StabilityError will be thrown.
See FileFrom for more information about how to provide an image.
See FileHandler for more information about how to handle the file response.
Classes
- Base64File
- Some endpoints returns files in base64 format.
- D3DModule
- A module for interacting with the Stable Fast 3D API.
- Engine
- An engine.
- EngineModule
- Enumerate engines that work with 'Version 1' REST API endpoints.
- FileFrom
- File source.
- FileHandler
- ImageStrength
- Use image_strength as image_init_mode
- ImageToVideoModule
- Image-to-Video
- InitImageAlpha
- Use INIT_IMAGE_ALPHA as mask_source
- InitImageMode
- To preserve only roughly 35% of the initial image, pass in either init_image_mode=IMAGE_STRENGTH and image_strength=0.35 or init_image_mode=STEP_SCHEDULE and step_schedule_start=0.65. Both of these are equivalent, however init_image_mode=STEP_SCHEDULE also lets you pass in step_schedule_end, which can provide an extra level of control for those who need it. For more details, see the specific fields below.
- MaskBlack
- Use MASK_IMAGE_BLACK as mask_source
- MaskSource
- The source of the mask image.
- MaskWhite
- Use MASK_IMAGE_WHITE as mask_source
- Prompt
- Prompt for the sdxl module.
- SDXLModule
- The SDXL module.
- SDXLWithMaskModule
- https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/masking
- StabilityAI
- The main class for interacting with the Stability AI API
- StabilityError
- Stability API Error
- StabilityOrganization
- A Stability AI organization.
- StabilityUser
- A Stability AI user.
- StableImageControl
- Tools for generating precise, controlled variations of existing images or sketches.
- StableImageEdit
- Tools for editing your existing images.
- StableImageGenerate
- Tools for generating new images or variations of existing images.
- StableImageModule
- Stable Image v2beta API
- StableImageUpscale
- Stable Image Upscale module.
- StepSchedule
- Use step_schedule as image_init_mode
- UserModule
- A module for interacting with the user API.
Enums
- AspectRatio
- Aspect ratio for image generation.
- ClipGuidancePreset
- Clip guidance preset.
- Diffusion3Model
- Generate an image using a Stable Diffusion 3 model:
- EngineType
- The type of the engine.
- FinishReason
-
Many endpoints which returns files, also returns
finish_reason
in headers or response body. - OutputFormat
- Output format for image generation.
- Sampler
- Sampler type.
- StylePreset
- Style preset for image generation.
- TextureResolution
- The resolution of the generated texture.