"Groq" (Service Connection)

This service connection requires an external account »

Use the Groq API with the Wolfram Language.

Connecting & Authenticating

ServiceConnect["Groq"] creates a connection to the Groq API. If a previously saved connection can be found, it will be used; otherwise, a new authentication request will be launched.
Use of this connection requires internet access and a Groq account.

Requests

ServiceExecute["Groq","request",params] sends a request to the Groq API, using parameters params. The following gives possible requests.
Request:

"TestConnection" returns Success for working connection, Failure otherwise

Text

Request:

"Chat" create a response for the given chat conversation

Parameters:
  • "Messages"(required)a list of messages in the conversation, each given as an association with "Role" and "Content" keys
    "FrequencyPenalty"Automaticpenalize tokens based on their existing frequency in the text so far (between -2 and 2)
    "MaxTokens"Automaticmaximum number of tokens to generate
    "Model"Automaticname of the model to use
    "N"Automaticnumber of completions to return
    "PresencePenalty"Automaticpenalize new tokens based on whether they appear in the text so far (between -2 and 2)
    "StopTokens"Automaticstrings where the API will stop generating further tokens
    "Stream"Falsereturn the result as server-sent events
    "Temperature"Automaticsampling temperature
    "ToolChoice"Automaticwhich (if any) tool is called by the model
    "Tools"Automaticone or more LLMTool objects available to the model
    "TotalProbabilityCutoff"Automatican alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with the requested probability mass
    "User"Automaticunique identifier representing the end user
  • Audio

    Request:

    "AudioTranscription" transcribe an audio recording into the input language

    Parameters:
  • "Audio"(required)the Audio object to transcribe
    "Language"Automaticlanguage of the input audio
    "Model"Automaticname of the model to use
    "Prompt"Noneoptional text to guide the model's style or continue a previous audio segment
    "Temperature"Automaticsampling temperature (between 0 and 1)
    "TimestampGranularities"Automaticthe timestamp granularity of transcription (either "word" or "segment")
  • Request:

    "AudioTranslation" translate an audio recording into English

    Parameters:
  • "Audio"(required)the Audio object to translate
    "Model"Automaticname of the model to use
    "Prompt"Noneoptional text to guide the model's style or continue a previous audio segment
    "Temperature"Automaticsampling temperature (between 0 and 1)
  • Model Lists

    Request:

    "ChatModelList" list models available for the "Chat" request

    Examples

    open allclose all

    Basic Examples  (1)

    Create a new connection:

    Generate a response from a chat:

    Scope  (5)

    Connection  (1)

    Test the connection:

    Text  (2)

    Chat  (1)

    Respond to a chat containing multiple messages:

    ChatModelList  (1)

    Look up the available chat models list:

    Audio  (2)

    AudioTranscription  (1)

    Transcribe an Audio object:

    Use a prompt to provide context for the transcription:

    Transcribe a recording made in a different language:

    Increase the temperature used for the sampling:

    AudioTranslation  (1)

    Translate an Audio object into English:

    Use a prompt to provide context for the translation:

    Increase the temperature used for the sampling: