🎨 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.

License: MIT


✨ Features

  • 🧠 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

πŸš€ 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.