chatgpt_client 1.1.2 copy "chatgpt_client: ^1.1.2" to clipboard
chatgpt_client: ^1.1.2 copied to clipboard

Access OpenAI ChatGPT Public API using Dart Language. Supports native Dart project and all Flutter target platforms (iOS, Android, Windows, Linux, Web)

example/main.dart

import 'package:chatgpt_client/chatgpt_client.dart';

void main() async {
  final client = ChatGPTClient(apiKey: "API_KEY");
  final prompt = "what is observable object?";

  /// Standard Response
  print("Standard Response");
  try {
    final text = await client.sendMessage(prompt);
    print(text);
  } catch (exception) {
    print(exception.toString());
  }

  /// Stream Response
  print("Stream Response");
  try {
    var text = "";
    final stream = client.sendMessageStream(prompt);
    await for (final textChunk in stream) {
      text += textChunk;
      print(textChunk);
    }
    print(text);
  } catch (exception) {
    print(exception.toString());
  }

  client.clearHistoryList();
}
15
likes
50
pub points
65%
popularity

Publisher

verified publisheralfianlosari.com

Access OpenAI ChatGPT Public API using Dart Language. Supports native Dart project and all Flutter target platforms (iOS, Android, Windows, Linux, Web)

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

fetch_client, http, web_browser_detect

More

Packages that depend on chatgpt_client