https://github.com/hrvojecukman/chat_gpt_flutter
https://github.com/hrvojecukman/chat_gpt_flutter
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/hrvojecukman/chat_gpt_flutter
- Owner: hrvojecukman
- License: mit
- Created: 2022-12-31T16:39:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-03T11:24:23.000Z (over 1 year ago)
- Last Synced: 2024-11-07T23:40:05.751Z (5 months ago)
- Language: Dart
- Size: 354 KB
- Stars: 19
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-ChatGPT - chat_gpt_flutter
- awesome-chatgpt - chat_gpt_flutter
README
ChatGPT API implemented in Flutter
[](https://www.buymeacoffee.com/hrvojecukman "Buy Me A Coffee")

## Getting started
You have to create OpenAI account and request API key from
here: https://beta.openai.com/account/api-keys## Stream usage
```dart
final chatGpt = ChatGpt(apiKey: apiKey);
final question =
'Which Disney character famously leaves a glass slipper behind at a royal ball?';final request = CompletionRequest(
prompt: question,
stream: true,
maxTokens: 4000,
model: ChatGptModel.textDavinci003.key,
);final stream = await chatGpt.createCompletionStream(request);
```
## Usage without stream```dart
final chatGpt = ChatGpt(apiKey: apiKey);
final testPrompt =
'Which Disney character famously leaves a glass slipper behind at a royal ball?';final testRequest = CompletionRequest(
prompt: testPrompt,
model: ChatGptModel.textDavinci003.key,
);final result = await chatGpt.createCompletion(testRequest);
```