LLMFunction
✖
LLMFunction
Details and Options




- An LLMFunction can be used to generate text using a large language model (LLM). It can create content, complete sentences, extract information and more.
- LLMFunction requires external service authentication, billing and internet connectivity.
- The prompti supports the following values:
-
"text" static text LLMPrompt["name"] a repository prompt StringTemplate[…] templated text TemplateObject[…] template for creating a prompt {prompt1,…} a list of prompts - Prompts created with TemplateObject can contain text and images. Not every LLM supports image input.
- LLMFunction supports the following options:
-
InsertionFunction TextString function or format to apply before inserting expressions CombinerFunction StringJoin function to apply to combine pieces within a prompt Authentication Automatic explicit user ID and API key LLMEvaluator $LLMEvaluator LLM configuration to use - LLMEvaluator can be set to an LLMConfiguration object or an association with any of the following keys:
-
"MaxTokens" maximum amount of tokens to generate "Model" base model "PromptDelimiter" string to insert between prompts "Prompts" initial prompts "StopTokens" tokens on which to stop generation "Temperature" sampling temperature "ToolMethod" method to use for tool calling "Tools" list of LLMTool objects to make available "TopProbabilities" sampling classes cutoff "TotalProbabilityCutoff" sampling probability cutoff (nucleus sampling) - Valid forms of "Model" include:
-
name named model {service,name} named model from service <"Service"service,"Name"name,"Task"task > fully specified model - The generated text is sampled from a distribution. Details of the sampling can be specified using the following properties of LLMEvaluator:
-
"Temperature"t Automatic sample using a positive temperature t "TopProbabilities"k Automatic sample only among the k highest-probability classes "TotalProbabilityCutoff"p Automatic sample among the most probable choices with an accumulated probability of at least p (nucleus sampling) - The setting "Temperature"Automatic resolves to zero temperature within LLMFunction. The other parameters use the default for the specified "Model".
- Multiple prompts are separated by the "PromptDelimiter" property of the LLMEvaluator.
- Possible values for Authentication are:
-
Automatic choose the authentication scheme automatically Environment check for a key in the environment variables SystemCredential check for a key in the system keychain ServiceObject[…] inherit the authentication from a service object assoc provide an explicit key and user ID - With AuthenticationAutomatic, the function checks the variable ToUpperCase[service]<>"_API_KEY" in Environment and SystemCredential; otherwise, it uses ServiceConnect[service].
- When using Authenticationassoc, assoc can contain the following keys:
-
"ID" user identity "APIKey" API key used to authenticate - LLMFunction uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Create a function for getting cooking instructions:

https://wolfram.com/xid/0btoeg7jfq0y-rwdua5


https://wolfram.com/xid/0btoeg7jfq0y-maeagy


https://wolfram.com/xid/0btoeg7jfq0y-3iiv4d

Create a function that returns a city as an Entity:

https://wolfram.com/xid/0btoeg7jfq0y-79qv1r


https://wolfram.com/xid/0btoeg7jfq0y-763od5

Scope (3)Survey of the scope of standard use cases

https://wolfram.com/xid/0btoeg7jfq0y-38j2bu

Apply it using an Association:

https://wolfram.com/xid/0btoeg7jfq0y-wstwh

Set a default for a parameter:

https://wolfram.com/xid/0btoeg7jfq0y-e5ycoy


https://wolfram.com/xid/0btoeg7jfq0y-s7r4l6

Use a multi-part prompt with images:

https://wolfram.com/xid/0btoeg7jfq0y-ubidct

Properties & Relations (1)Properties of the function, and connections to other functions
LLMFunction with no parameters sends the prompt directly to the LLM:

https://wolfram.com/xid/0btoeg7jfq0y-uecth4

This is equivalent to LLMSynthesize with zero temperature:

https://wolfram.com/xid/0btoeg7jfq0y-dlby6x

Wolfram Research (2023), LLMFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMFunction.html.
Text
Wolfram Research (2023), LLMFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMFunction.html.
Wolfram Research (2023), LLMFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMFunction.html.
CMS
Wolfram Language. 2023. "LLMFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LLMFunction.html.
Wolfram Language. 2023. "LLMFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LLMFunction.html.
APA
Wolfram Language. (2023). LLMFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMFunction.html
Wolfram Language. (2023). LLMFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMFunction.html
BibTeX
@misc{reference.wolfram_2025_llmfunction, author="Wolfram Research", title="{LLMFunction}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/LLMFunction.html}", note=[Accessed: 13-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_llmfunction, organization={Wolfram Research}, title={LLMFunction}, year={2023}, url={https://reference.wolfram.com/language/ref/LLMFunction.html}, note=[Accessed: 13-May-2025
]}