The Groq AI SDK for Dart allows developers to use Large Language Models (LLMs) to build language applications.
To use the Groq API, you'll need an API key. If you don't already have one, create a key in GroqCloud: https://console.groq.com/playground.
See an example app at samples/dart, including some getting started instructions.
Add a dependency on the package:groq
package via:
dart pub add groq
or:
flutter pub add groq
flutter run --dart-define=groqApiKey='Your Api Key'
import 'package:groq/groq.dart';
final groq = Groq(apiKey: const String.fromEnvironment('groqApiKey'));
groq.startChat();
try {
GroqResponse response = await groq.sendMessage(text);
print(response.choices.first.message.content)
} on GroqException catch (error) {
print(error.message)
}
groq.startChat();
groq.setCustomInstructionsWith(instructions);
try {
GroqResponse response = await groq.sendMessage(text);
print(response.choices.first.message.content)
} on GroqException catch (error) {
print(error.message)
}