openai_image_edit 0.0.2
openai_image_edit: ^0.0.2 copied to clipboard
OpenAI image generation and edit package using gpt-image-1 model
π¨ openai_image_edit #
A minimal and flexible Flutter package to interact with OpenAIβs gpt-image-1 model for image editing and generation, using natural language prompts and one or more image inputs.
β¨ Features #
- π§ Interact with
gpt-image-1for smart image editing - πΌοΈ Generate new images from text prompts
- π¦ Easy integration with
http,dio, or other networking tools - π§ͺ Typed responses and
base64decoding included - π Works with your OpenAI API key
π Getting Started #
1. Add Dependency #
In your pubspec.yaml:
dependencies:
openai_image_edit: ^0.0.1
Then run:
flutter pub get
π οΈ Usage #
π§ Initialize the Client #
final client = OpenAIImageEditClient(apiKey: 'your-api-key-here');
π§ Image Edit Example #
```dart
final imageBytes = await loadImageAsBytes('sunset_image.png');
final imageData = await client.editImages(
prompt: "Make the image more futuristic",
images: [imageBytes],
size: OpenAIImageSize.x1536x1024);
if (imageData.isNotEmpty) {
await saveImage(imageData.first);
} else {
print('No image was returned.');
}
```
π¨ Image Generation Example #
```dart
final imageData = await client.generateImage(
prompt: "Draw a cat in a basket",
size: OpenAIImageSize.x1536x1024);
if (imageData.isNotEmpty) {
await saveImage(imageData.first);
} else {
print('No image was returned.');
}
```
π¦ Supported Sizes #
enum OpenAIImageSize {
x1024x1024,
x1536x1024,
x1024x1536,
auto
}
π§ͺ Testing #
You can test the core methods using:
flutter test
Make sure to include a valid .env or pass your API key securely during tests.
π License #
This package is released under the MIT License. See LICENSE for details.
π¬ Contributions #
Feel free to open issues, PRs, or discussions! Contributions are welcome.