Sends its text as a prompt to a language model (Claude) and stores the answer. @llm(prompt, ...) takes the same options and returns the answer instead, for a prompt that is already a value.
Holds text with { } values. Scripts only.
AttributeOption
Value
Description
intorequired
a new variable's name
The variable that receives the answer.
system
a string with { }
The system prompt.
schema
expression
Ask for structured output: a map describing the fields, such as { category: 'bug|feature', urgency: 'int 1-5' }. The answer is then a map.
tools
a list of functions: [a, b]
<fn> functions the model may call: [@lookup, @weather] (in XML, tools="lookup, weather").fn functions the model may call: [@lookup, @weather] (in XML, tools="lookup, weather").
model
a string
The model to use (default: claude-opus-5-5, or KSCRIPT_AI_MODEL).
max_tokens
expression
The longest answer, in tokens (default 16000).
Example
<llm into="reply" system="Answer in Markdown.">
Customer {$customer.name} wrote: {$message}
</llm>
llm(into: reply, system: 'Answer in Markdown.') "Customer {$customer.name} wrote: {$message}"
Commands
Commands are called with @, in any expression: @name(arguments).
For tests: from now on in this run, @llm, llm and $chat->ask() answer from replies instead of asking Claude: a list used in order, or fn(prompt) => answer. A map reply answers a question with a schema. $fake->prompts() lists what was asked.
Parameter
Takes
repliesrequired
list|fn
Example
<let name="fake" value="@fake_llm(['Paris'])" />
<echo>{ @llm('What is the capital of France?') }</echo>
<echo>{ $fake->prompts() }</echo>
$fake = @fake_llm(['Paris'])
echo @llm('What is the capital of France?')
echo $fake->prompts()
#@llm(prompt, system?, schema?, tools?, model?, max_tokens?: number)→ any
Asks a language model (Claude) and returns its answer. The options are the llm statement's, given by name: system (the system prompt), schema (a map of fields; the answer is then a map), tools (<fn> functions it may call), model and max_tokens.Asks a language model (Claude) and returns its answer. The options are the llm statement's, given by name: system (the system prompt), schema (a map of fields; the answer is then a map), tools (fn functions it may call), model and max_tokens.