- See Also
-
Related Guides
- Machine Learning
- Knowledge Representation & Access
- Natural Language Processing
- LLM-Related Functionality
- Text Generation
- Automated Reports
- Accessing External Services & APIs
- Text Manipulation
- Notebook Document Generation
- String Manipulation
- Converting between Expressions & Strings
- Neural Networks
- Text Analysis
-
- See Also
-
Related Guides
- Machine Learning
- Knowledge Representation & Access
- Natural Language Processing
- LLM-Related Functionality
- Text Generation
- Automated Reports
- Accessing External Services & APIs
- Text Manipulation
- Notebook Document Generation
- String Manipulation
- Converting between Expressions & Strings
- Neural Networks
- Text Analysis
LLMSynthesize[prompt]
generates text according to the input prompt.
LLMSynthesize[{prompt1,…}]
combines multiple prompti together.
LLMSynthesize[…,prop]
returns the specified property of the generated text.
LLMSynthesize
LLMSynthesize[prompt]
generates text according to the input prompt.
LLMSynthesize[{prompt1,…}]
combines multiple prompti together.
LLMSynthesize[…,prop]
returns the specified property of the generated text.
Details and Options
- LLMSynthesize generates text according to the instruction in the prompt using a large language model (LLM). It can create content, complete sentences, extract information and more.
- LLMSynthesize requires external service authentication, billing and internet connectivity.
- Possible values for prompt can be:
-
"text" static text LLMPrompt["name"] a repository prompt StringTemplate[…] templated text TemplateObject[…] template for creating a prompt Image[…] an image {prompt1,…} a list of prompts - Template objects are automatically converted to strings via TemplateObject[…][].
- A prompt created with TemplateObject can contain text and images.
- Not every LLM supports image input.
- Supported values for prop include:
-
"CompletionText" textual answer by the LLM "CompletionToolsText" textual answer including tool interactions "FormattedBoxes" completion formatted as Notebook Assistant boxes "FormattedText" formatted "Markdown" completion "FullText" string representation of "History" "History" complete history including prompt and completion "LLMEvaluator" runtime LLMEvaluator value "NotebookObject" formatted completion in a new notebook "Prompt" content submitted to the LLM "PromptText" string representation of "Prompt" "ToolRequests" list of LLMToolRequest objects "ToolResponses" list of LLMToolResponse objects "Usage" token usage {prop1,prop2,…} multiple properties All all properties - "FullTextAnnotations", "ToolRequests" and "ToolResponses" give associations with elements in the format {start,end}val, where val refers to an object and start and end refer to the span of characters where val is specified in "FullText".
- The following options can be specified:
-
Authentication Automatic authentication scheme LLMEvaluator $LLMEvaluator LLM configuration to use ProgressReporting $ProgressReporting how to report the progress of the computation - 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 or LLMPromptGenerator objects "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 - Possible values for task include "Chat" and "Completion".
- The generated text is sampled from a distribution. Details of the sampling can be specified using the following properties of the 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 Automatic value of these parameters uses the default for the specified "Model".
- Prompts specified in the "Prompts" property of the LLMEvaluator are prepended to the input prompt with role set as "System" if task is "Chat"
- 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 "string" provide an explicit API key - With AuthenticationAutomatic, the function checks the variable ToUpperCase[service]<>"_API_KEY" in Environment and SystemCredential; otherwise, it uses ServiceConnect[service].
- LLMSynthesize 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 all close allBasic Examples (3)
Scope (4)
Synthesize text based on a prompt:
LLMSynthesize["the product of 5 and 6 is "]Use a prompt with both text and images:
LLMSynthesize[{"what is this image?", [image], "Tell me just one word about it"}, LLMEvaluator -> <|"Model" -> {"OpenAI", "gpt-4o"}|>]LLMSynthesize["the product of 5 and 6 is ", "FullText"]Import the completion text as formatted boxes:
LLMSynthesize["what is the tallest mountain?", "FormattedBoxes", LLMEvaluator -> "AgentOne"]Options (10)
Authentication (4)
Provide an authentication key for the API:
LLMSynthesize["the product of 5 and 6 is ", Authentication -> "<my-key>"]Store the API key using the operating system's keychain:
SystemCredential["OPENAI_API_KEY"] = "<my-key>"Look for the key in the system keychain:
LLMSynthesize["the product of 5 and 6 is ", Authentication -> SystemCredential]Store the API key in an environment variable:
SetEnvironment["OPENAI_API_KEY" -> "<my-key>"]Look for the key in the system environment:
LLMSynthesize["the product of 5 and 6 is ", Authentication -> Environment]Authenticate via a service object:
so = ServiceConnect["OpenAI"]LLMSynthesize["the product of 5 and 6 is ", Authentication -> so]LLMEvaluator (5)
Use the Wolfram computationally assisted generation (CAG):
LLMSynthesize["the first 100 digits of Pi", LLMEvaluator -> "WolframAIAssistant"]By default, the text generation continues until a termination token is generated:
LLMSynthesize["answer with only the first 20 digits of Pi"]Limit the amount of generated samples (tokens):
LLMSynthesize["answer with only the first 20 digits of Pi", LLMEvaluator -> <|"Model" -> "gpt-4o-mini", "MaxTokens" -> 3|>]Specify that the sampling should be performed at zero temperature:
Table[LLMSynthesize["Answer with random a color", LLMEvaluator -> <|"Model" -> "gpt-4o-mini", "Temperature" -> 0|>], 3]Specify a high temperature to get more variation in the generation:
Table[LLMSynthesize["Answer with a random color", LLMEvaluator -> <|"Model" -> "gpt-4o-mini", "Temperature" -> 1.5|>], 3]Specify the maximum cumulative probability before cutting off the distribution:
LLMSynthesize["What's the plural of mouse?", LLMEvaluator -> <|"TotalProbabilityCutoff" -> .2, "Model" -> "gpt-4o-mini"|>]Specify the service and the model to use for the generation:
LLMSynthesize["What's the plural of mouse?", LLMEvaluator -> <|"Model" -> {"Anthropic", "claude-haiku-4-5-20251001"}|>]Applications (2)
Define a function that builds a prompt programmatically:
promptfunction[prompt_][args___] := LLMSynthesize[TemplateApply[prompt, {args}]]Use it to create a natural language synonym generator:
synonyms = promptfunction["write `2` synonyms of `1`"]Apply it to a sequence of arguments:
synonyms["city", 2]Get personalized instruction about the Wolfram Language:
LLMSynthesize["Plot a rational polynomial in the complex plane", "FormattedBoxes", LLMEvaluator -> "WolframAIAssistant"]Click "Insert and evaluate" on the suggested expression:
ComplexPlot[(z ^ 2 + 1) / (z ^ 2 - 1), {z, -2 - 2 I, 2 + 2 I}]Possible Issues (3)
The text generation is not guaranteed to follow instructions to the letter:
pi = LLMSynthesize["Pi to the 57th decimal digit"]StringLength[pi]Use exact arithmetic for precise computations:
N[Pi, 57 + 1]Some models may only support a subset of the possible generation settings:
LLMSynthesize["Answer with random a color", LLMEvaluator -> <|"Temperature" -> 0|>]Tokens used by the model, such as reasoning ones, may not appear in the output:
LLMSynthesize["answer with only the first 20 digits of Pi", LLMEvaluator -> <|"MaxTokens" -> 3|>]Related Guides
-
▪
- Machine Learning ▪
- Knowledge Representation & Access ▪
- Natural Language Processing ▪
- LLM-Related Functionality ▪
- Text Generation ▪
- Automated Reports ▪
- Accessing External Services & APIs ▪
- Text Manipulation ▪
- Notebook Document Generation ▪
- String Manipulation ▪
- Converting between Expressions & Strings ▪
- Neural Networks ▪
- Text Analysis
History
Introduced in 2023 (13.3) | Updated in 2024 (14.0) ▪ 2024 (14.1) ▪ 2025 (14.2) ▪ 2026 (15.0)
Text
Wolfram Research (2023), LLMSynthesize, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMSynthesize.html (updated 2026).
CMS
Wolfram Language. 2023. "LLMSynthesize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/LLMSynthesize.html.
APA
Wolfram Language. (2023). LLMSynthesize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMSynthesize.html
BibTeX
@misc{reference.wolfram_2026_llmsynthesize, author="Wolfram Research", title="{LLMSynthesize}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/LLMSynthesize.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_llmsynthesize, organization={Wolfram Research}, title={LLMSynthesize}, year={2026}, url={https://reference.wolfram.com/language/ref/LLMSynthesize.html}, note=[Accessed: 12-June-2026]}