https://github.com/trevorwang/openai_dart
https://github.com/trevorwang/openai_dart
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/trevorwang/openai_dart
- Owner: trevorwang
- License: mit
- Created: 2023-03-20T09:36:56.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-04T09:20:48.000Z (12 months ago)
- Last Synced: 2025-03-27T04:41:42.399Z (29 days ago)
- Language: Dart
- Size: 1.9 MB
- Stars: 9
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# openai_api
[](https://pub.dartlang.org/packages/openai_api)
[](https://github.com/trevorwang/openai_api)## Features
APIs have been supported by this library. Update to support latest models. Now you can use the API to create speech and generate images with Dall-E 3.
- [x] Chat
- [x] Images
- [x] Audio
- [x] TTS
- [X] STT
- [x] Models
- [ ] Edits
- [ ] Completions
- [ ] Embeddings
- [ ] Files
- [ ] Fine-tunes
- [ ] Moderations
- [ ] Engines## Usge
### Initialize Openai Client
```dart
final client = OpenaiClient(
config: OpenaiConfig(
apiKey: Env.apiKey, // your api key from openai.com
baseUrl: Env.baseUrl, // you can set your reverse proxy api
httpProxy: Env.httpProxy, // if you need access api through http proxy
),
);```
### Then call the APIs
- Audio Transcription
```dart
final result = await client.createTranscription(
TranscriptionRequest(
file: 'assets/ttsmaker-file-2023-3-22-14-57-0.mp3',
),
);
print(result.text);
```- Audio Translation
```dart
final translateResult = await client.createTraslation(
TranslationRequest(
file: 'assets/ttsmaker-file-2023-3-22-17-27-30.mp3',
// file: "assets/ttsmaker-file-2023-3-22-14-2-35.mp3",
// Wierd. this will be translated into Pinyin for Chinese if prompt not set.
// 你好朋友,我好想你。
// Ni Hao Peng You, Wo Hao Xiang Ni
// prompt: "Please translate into Chinese.",
),
);
```
## Contributors ✨Thanks goes to these wonderful people:
Contributions of any kind welcome!
## Activities