"AI21" (Service Connection)
Connecting & Authenticating
ServiceConnect["AI21"] creates a connection to the AI21 API. If a previously saved connection can be found, it will be used; otherwise, a new authentication request will be launched.
Requests
ServiceExecute["AI21","request",params] sends a request to the AI21 API, using parameters params. The following gives possible requests.
Text
"Chat" — create a response for the given chat conversation
"Messages" | (required) | a list of messages in the conversation, each given as an association with "Role" and "Content" keys | |
"FrequencyPenalty" | Automatic | penalize tokens based on their existing frequency in the text so far (between -2 and 2) | |
"MaxTokens" | Automatic | maximum number of tokens to generate | |
"Model" | Automatic | name of the model to use | |
"N" | Automatic | number of completions to return | |
"PresencePenalty" | Automatic | penalize new tokens based on whether they appear in the text so far (between -2 and 2) | |
"StopTokens" | Automatic | strings where the API will stop generating further tokens | |
"Stream" | False | return the result as server-sent events | |
"Temperature" | Automatic | sampling temperature |
Model Lists
"ChatModelList" — list models available for the "Chat" request
See Also
ServiceExecute ▪ ServiceConnect ▪ LLMFunction ▪ LLMSynthesize ▪ ChatEvaluate ▪ LLMConfiguration
Service Connections: AlephAlpha ▪ Anthropic ▪ Cohere ▪ DeepSeek ▪ GoogleGemini ▪ MistralAI ▪ OpenAI ▪ TogetherAI