Groq class

Constructors

Groq(String apiKey)
Creates a new Groq instance
apiKey is the API key to use the Groq API
You can communicate with the Groq API via a Chat instance
Example:

Properties

apiKey String
The API key to use the Groq API
Obtain it from the Groq website:
https://console.groq.com/keys
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canUseModel(String modelId) Future<bool>
Returns whether the model with the given model id can be used
It returns true if the model is currently active and false otherwise
Example:
getModel(String modelId) Future<GroqLLMModel>
Returns the model metadata from groq with the given model id \
isTextHarmful({required String text, String? customApiKey}) Future<(bool, GroqLlamaGuardCategory?, GroqUsage, GroqRateLimitInformation?)>
Checks if the given text is harmful
customApiKey is the API key to use for the check, defaults to the Groq instance API key
Returns whether the text is harmful, the harmful category and the rate limit information
Example:
listModels() Future<List<GroqLLMModel>>
Returns a list of all model metadatas available in Groq \
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startNewChat(String modelId, {GroqChatSettings settings = const GroqChatSettings.defaults(), String? customApiKey}) GroqChat
Returns a new chat instance with the given model id
modelId is the model id to use for the chat
settings are the chat settings, defaults to GroqChatSettings.defaults()
customApiKey is the API key to use for the chat, defaults to the Groq instance API key
Example:
toString() String
A string representation of this object.
inherited
transcribeAudio({required String audioFileUrl, required String modelId, String? customApiKey, Map<String, String> optionalParameters = const {}}) Future<(GroqAudioResponse, GroqRateLimitInformation)>
Transcribes the audio file at the given audioFileUrl, max 25Mb
It uses the model with the given modelId
customApiKey is the API key to use for the transcription, defaults to the Groq instance API key
Returns the transcribed audio response, the usage of the groq resources and the rate limit information
Example:
translateAudio({required String audioFileUrl, required String modelId, String? customApiKey, double temperature = 0.5}) Future<(GroqAudioResponse, GroqRateLimitInformation)>
Translates the audio file at the given audioFileUrl to ENGLISH, max 25Mb
It uses the model with the given modelId
customApiKey is the API key to use for the translation, defaults to the Groq instance API key
temperature is the randomness of the translation, defaults to 0.5
Returns the translated audio response, the usage of the groq resources and the rate limit information
Example:

Operators

operator ==(Object other) bool
The equality operator.
inherited