chatgpt_client 1.1.0 copy "chatgpt_client: ^1.1.0" to clipboard
chatgpt_client: ^1.1.0 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
0
pub points
23%
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

unknown (license)

Dependencies

fetch_client, http

More

Packages that depend on chatgpt_client