groq 0.0.5 groq: ^0.0.5 copied to clipboard
The Groq Dart SDK enables developers to use Groq's api. Groq is on a mission to set the standard for GenAI inference speed, helping real-time AI applications come to life today.
Groq Generative AI #
The Groq AI SDK for Dart allows developers to use Large Language Models (LLMs) to build language applications.
Getting Started #
API keys #
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.
Examples #
See an example app at samples/dart, including some getting started instructions.
Using the SDK in your own app #
Add a dependency on the package:groq
package via:
dart pub add groq
or:
flutter pub add groq
Set the API key #
flutter run --dart-define=groqApiKey='Your Api Key'
Import package #
import 'package:groq/groq.dart';
Initializing the API client #
final groq = Groq(apiKey: const String.fromEnvironment('groqApiKey'));
Calling the API #
To send a message
groq.startChat();
try {
GroqResponse response = await groq.sendMessage(text);
print(response.choices.first.message.content)
} on GroqException catch (error) {
print(error.message)
}
To set helpful information for assistant
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)
}