{"id":13645964,"url":"https://github.com/coskuncay/flutter_chatgpt_api","last_synced_at":"2025-10-22T22:46:37.902Z","repository":{"id":64328762,"uuid":"574940740","full_name":"coskuncay/flutter_chatgpt_api","owner":"coskuncay","description":"Use ChatGPT from Flutter / Dart","archived":false,"fork":false,"pushed_at":"2022-12-23T18:19:02.000Z","size":97,"stargazers_count":175,"open_issues_count":9,"forks_count":43,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-09T19:39:53.309Z","etag":null,"topics":["chatgpt","chatgpt-dart","chatgpt-flutter","dart","flutter"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_chatgpt_api","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coskuncay.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-06T12:11:58.000Z","updated_at":"2024-11-08T08:16:54.000Z","dependencies_parsed_at":"2023-01-15T12:30:58.034Z","dependency_job_id":null,"html_url":"https://github.com/coskuncay/flutter_chatgpt_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coskuncay%2Fflutter_chatgpt_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coskuncay%2Fflutter_chatgpt_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coskuncay%2Fflutter_chatgpt_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coskuncay%2Fflutter_chatgpt_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coskuncay","download_url":"https://codeload.github.com/coskuncay/flutter_chatgpt_api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100503,"owners_count":21374958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","chatgpt-dart","chatgpt-flutter","dart","flutter"],"created_at":"2024-08-02T01:02:45.930Z","updated_at":"2025-10-22T22:46:37.837Z","avatar_url":"https://github.com/coskuncay.png","language":"Dart","funding_links":["https://github.com/sponsors/coskuncay"],"categories":["Others"],"sub_categories":[],"readme":"# Flutter ChatGPT API\n\nThis package is a Flutter/Dart API around [ChatGPT](https://openai.com/blog/chatgpt) by [OpenAI](https://openai.com).  \n\nThis package requires a valid session token from ChatGPT to access its unofficial REST API.\n\nThis version have been updated to use Puppeteer to log in to ChatGPT and extract the Cloudflare cf_clearance cookie and OpenAI session token. 🔥 Thanks to [Node.js ChatGPT API](https://github.com/transitive-bullshit/chatgpt-api) (unofficial)\n\n- [Demo](#demo)\n- [Installation](#installation)\n- [Usage](#usage) \n- [SessionToken and ClearanceToken](#sessiontoken) \n- [License](#license)\n\n:warning: Be Careful!\n- Your `user-agent` and `IP address` **must match** from the real browser window you're logged in with to the one you're using for `ChatGPTAPI`.\n  - This means that you currently can't log in with your laptop and then run the bot on a server or proxy somewhere.\n- Please check `defaultHeaders`\n## Demo\n\n\u003cimg src=\"https://user-images.githubusercontent.com/29631083/205933816-7e200521-7355-43e2-a41e-2a22c7b4c2c2.gif\" width=\"300\"/\u003e\u003c/a\u003e\n \n## Installation\n\n```\ndependencies:\n  flutter_chatgpt_api: ^1.0.0\n```\n\n## Usage\n\n```dart\n\nimport 'package:flutter_chatgpt_api/flutter_chatgpt_api.dart';\n\n _api = ChatGPTApi(\n       sessionToken: SESSION_TOKEN,\n       clearanceToken: CLEARANCE_TOKEN,\n     );\n\nsetState(() {\n  _messages.add(\n    ChatMessage(\n      text: _textController.text,\n      chatMessageType: ChatMessageType.user,\n    ),\n  );\n  isLoading = true;\n});  \n\nvar newMessage = await _api.sendMessage(\n  input,\n  conversationId: _conversationId,\n  parentMessageId: _parentMessageId,\n);\n\nsetState(() {\n  _conversationId = newMessage.conversationId;\n  _parentMessageId = newMessage.messageId;\n  isLoading = false;\n  _messages.add(\n    ChatMessage(\n      text: newMessage.message,\n      chatMessageType: ChatMessageType.bot,\n    ),\n  );\n});\n```\n## SessionToken \n\nTo get a session token:\n\n1. Go to https://chat.openai.com/chat and log in or sign up.\n2. Open dev tools.\n3. Open `Application` \u003e `Cookies` (`Storage` \u003e `Cookies`)\n   \n ![image](https://user-images.githubusercontent.com/29631083/207098307-bbe78b3d-0704-42f2-828e-70e2b71691af.png)\n   \n4. Create these files and add your session token to run the tests and example respectively:\n\n\nCopy the value for __Secure-next-auth.session-token and save it to your environment.`example/lib/session_token.dart`\n \nCopy the value for cf_clearance and save it to your environment.\n`example/lib/clearance_token.dart`\n\nShould look something like this:\n```dart\nconst SESSION_TOKEN = '__Secure-next-auth.session-token from https://chat.openai.com/chat';\n```\n\n```dart\nconst CLEARANCE_TOKEN = 'cf_clearance token from https://chat.openai.com/chat';\n```\n## Credit\n\n- Huge thanks to \u003ca href=\"https://twitter.com/transitive_bs\"\u003eTravis Fischer\u003c/a\u003e for creating [Node.js ChatGPT API](https://github.com/transitive-bullshit/chatgpt-api) (unofficial) 💪\n- Inspired by this [ChatGPT API Dart](https://github.com/MisterJimson/chatgpt_api_dart) by [Jason Rai](https://github.com/MisterJimson) ✨\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/) Copyright (c) 2022, [Emre Coşkunçay](https://github.com/coskuncay)\n\nIf you found this project interesting, please consider supporting my open source work by [sponsoring me](https://github.com/sponsors/coskuncay) or \u003ca href=\"https://twitter.com/justecdev\"\u003efollowing me on twitter \u003cimg src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"\u003e\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoskuncay%2Fflutter_chatgpt_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoskuncay%2Fflutter_chatgpt_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoskuncay%2Fflutter_chatgpt_api/lists"}