flutter_chatgpt_api 1.1.0 copy "flutter_chatgpt_api: ^1.1.0" to clipboard
flutter_chatgpt_api: ^1.1.0 copied to clipboard

Flutter/Dart API around ChatGPT for the unofficial ChatGPT API.

Flutter ChatGPT API #

This package is a Flutter/Dart API around ChatGPT by OpenAI.

This package requires a valid session token from ChatGPT to access its unofficial REST API.

Demo #

Installation #

dependencies:
  flutter_chatgpt_api: ^1.0.0

Usage #


import 'package:flutter_chatgpt_api/flutter_chatgpt_api.dart';

 _api = ChatGPTApi(sessionToken: SESSION_TOKEN);

setState(() {
  _messages.add(
    ChatMessage(
      text: _textController.text,
      chatMessageType: ChatMessageType.user,
    ),
  );
  isLoading = true;
});  

var newMessage = await _api.sendMessage(
  input,
  conversationId: _conversationId,
  parentMessageId: _parentMessageId,
);

setState(() {
  _conversationId = newMessage.conversationId;
  _parentMessageId = newMessage.messageId;
  isLoading = false;
  _messages.add(
    ChatMessage(
      text: newMessage.message,
      chatMessageType: ChatMessageType.bot,
    ),
  );
});

SessionToken #

To get a session token:

  1. Go to https://chat.openai.com/chat and log in or sign up.
  2. Open dev tools.
  3. Open Application > Cookies (Storage > Cookies on FireFox)

image

  1. Create these files and add your session token to run the tests and example respectively:
  • test/session_token.dart
  • example/lib/session_token.dart

Should look something like this:

const SESSION_TOKEN = 'my session token from https://chat.openai.com/chat';

Credit #

License #

MIT Copyright (c) 2022, Emre Coşkunçay

If you found this project interesting, please consider supporting my open source work by sponsoring me or following me on twitter twitter

100
likes
130
pub points
69%
popularity

Publisher

verified publisherjustec.dev

Flutter/Dart API around ChatGPT for the unofficial ChatGPT API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http, uuid

More

Packages that depend on flutter_chatgpt_api