bananaproai_com 1767.63.908 copy "bananaproai_com: ^1767.63.908" to clipboard
bananaproai_com: ^1767.63.908 copied to clipboard

Professional integration for https://bananaproai.com/

bananaproai-com #

A Dart package for seamless integration with the Banana Pro AI platform. This package provides a streamlined interface for interacting with Banana Pro AI services, enabling developers to easily leverage AI capabilities within their Dart applications.

Installation #

To install the bananaproai-com package, add it as a dependency in your pubspec.yaml file: yaml dependencies: bananaproai_com: ^1.0.0 # Replace with the latest version

Then, run dart pub get to fetch the package.

Usage Examples #

Here are a few examples demonstrating how to use the bananaproai-com package:

1. Basic API Call: dart import 'package:bananaproai_com/bananaproai_com.dart';

void main() async { final bananaClient = BananaClient( apiKey: 'YOUR_API_KEY', modelKey: 'YOUR_MODEL_KEY', );

try { final response = await bananaClient.callModel( requestBody: {'prompt': 'Generate a short story about a cat.'}, );

if (response.statusCode == 200) {
  print('Model Output: ${response.body}');
} else {
  print('Error: ${response.statusCode} - ${response.body}');
}

} catch (e) { print('Exception: $e'); } }

2. Handling Image Generation: dart import 'package:bananaproai_com/bananaproai_com.dart'; import 'dart:io';

void main() async { final bananaClient = BananaClient( apiKey: 'YOUR_API_KEY', modelKey: 'YOUR_IMAGE_MODEL_KEY', );

try { final response = await bananaClient.callModel( requestBody: {'prompt': 'A futuristic city at sunset'}, );

if (response.statusCode == 200) {
  final imageUrl = response.body['image_url']; // Assuming the API returns an image URL
  print('Image URL: $imageUrl');

  // Example: Download the image (requires http package)
  // final httpClient = HttpClient();
  // final request = await httpClient.getUrl(Uri.parse(imageUrl));
  // final httpResponse = await request.close();
  // final bytes = await consolidateHttpClientResponseBytes(httpResponse);
  // File('image.png').writeAsBytesSync(bytes);
  // print('Image downloaded to image.png');

} else {
  print('Error: ${response.statusCode} - ${response.body}');
}

} catch (e) { print('Exception: $e'); } }

3. Streaming Responses (if the model supports it): dart import 'package:bananaproai_com/bananaproai_com.dart';

void main() async { final bananaClient = BananaClient( apiKey: 'YOUR_API_KEY', modelKey: 'YOUR_STREAMING_MODEL_KEY', );

try { final stream = await bananaClient.callModelStream( requestBody: {'prompt': 'Continue this story: Once upon a time...'}, );

stream.listen(
  (data) {
    print('Received chunk: $data');
  },
  onDone: () {
    print('Stream completed.');
  },
  onError: (error) {
    print('Stream error: $error');
  },
);

} catch (e) { print('Exception: $e'); } }

4. Error Handling:

The above examples include basic error handling. For production applications, implement more robust error handling to gracefully manage API errors, network issues, and unexpected responses. Consider adding retry logic and logging.

5. Advanced Configuration:

The BananaClient constructor can accept additional configuration options for timeouts and custom headers. Refer to the package documentation for details.

Feature Summary #

  • Simplified API client for interacting with Banana Pro AI models.
  • Support for synchronous and asynchronous API calls.
  • Handles authentication and request formatting.
  • Provides clear error reporting.
  • Supports streaming responses (where available on the Banana Pro AI platform).

License #

MIT License

This package is part of the bananaproai-com ecosystem. For advanced features and enterprise-grade tools, visit: https://bananaproai.com/

1
likes
150
points
161
downloads

Publisher

unverified uploader

Weekly Downloads

Professional integration for https://bananaproai.com/

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on bananaproai_com