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.
- 🧠 Interact with
gpt-image-1
for smart image editing - 🖼️ Generate new images from text prompts
- 📦 Easy integration with
http
,dio
, or other networking tools - 🧪 Typed responses and
base64
decoding included - 🔐 Works with your OpenAI API key
In your pubspec.yaml
:
dependencies:
openai_image_edit: ^0.0.1
Then run:
flutter pub get
final client = OpenAIImageEditClient(apiKey: 'your-api-key-here');
```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.'); } ```
```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.'); } ```
enum OpenAIImageSize {
x1024x1024,
x1536x1024,
x1024x1536,
auto
}
You can test the core methods using:
flutter test
Make sure to include a valid .env
or pass your API key securely during tests.
This package is released under the MIT License. See LICENSE for details.
Feel free to open issues, PRs, or discussions! Contributions are welcome.