Skip to main content
Version: 6.2

ai

Description​

The command sends a request to an external language model.

Note!

The command requires a configured sm-ai service to work.

Syntax​

... | ai [model="<model>"] [output="<field>[,<field>]"] [mode=summary|per_row] [preset=<preset>] [system_message="<text>"] [user_message="<text>"] [input="<field>[,<field>]"|"*"] [temperature=<number>] [max_tokens=<int>] [max_prompt_tokens=<int>] [timeout=<int>]
info

You can omit model and output if they are set in the preset specified by the preset argument. Otherwise, both arguments are required.


Optional Arguments​

ParameterSyntaxDefault ValueDescription
modelmodel="<model_name>"From the selected presetName of the language model registered in the model registry.
outputoutput="<field>[,<field>]"From the selected presetResult field name or comma-separated list of result field names.
modemode=summary or mode=per_rowsummaryProcessing mode: summary reduces the entire context to one result row; per_row enriches each row with fields from output.
presetpreset=<preset_name>Name of a preset with predefined parameters. Explicit command arguments take precedence over preset values.
system_messagesystem_message="<text>"Model system instruction.
user_messageuser_message="<text>"Model user instruction.
inputinput="<field>[,<field>]" or input="*"*Row fields passed as context; * means all fields.
temperaturetemperature=<number>Generation temperature.
max_tokensmax_tokens=<int>Response token limit.
max_prompt_tokensmax_prompt_tokens=<int>60000Prompt token limit.
timeouttimeout=<int>Taken from sme.ai.timeoutProvider request timeout, ms.
info

Presets are configured in the system interface. Preset parameters apply by default; explicit command arguments take precedence over them.


Processing Modes​

summary (default)​

Transforms the entire set of rows into one result:

  1. One LLM call is executed for the entire context
  2. One result row is returned
  3. The result row contains only fields from output
  4. For multiple output fields, a JSON object is expected in the model response

per_row​

Enriches each source row with output fields:

  1. One LLM call is executed for all rows
  2. A response with results for each row is expected
  3. Source fields are preserved in the result rows and enriched with output fields
  4. If input limits the context, only specified fields go into the prompt, but final rows are taken from the source and enriched with output fields

System Settings​

Settings are stored in _cluster/settings. The table below presents ai command settings and their default values.

NameDescriptionDefault Value
sme.ai.inference_server_urlInference service base URL.http://localhost
sme.ai.inference_server_portInference service port.8010
sme.ai.timeoutInference service request timeout, ms.300000

Query Examples​

Example 1​

Example of using summary to analyze a k8s trace.

source k8s_otel_traces
| search traceId="6955d7042d2182d3be9a840e15bbb3ee"
| ai model="gpt-oss-20b" user_message="What's wrong with this trace" output="summary"

Result (one row):

[
{"summary": "There is a connection error to adservice in the trace."}
]

Example 2​

Example of using per_row with multiple result fields: semantic search with row enrichment.

source soc_events_prod
| semanticsearch
vector_field="event_embedding"
query="Signs of lateral movement via remote command execution and credential theft"
model_id="zXjJepwBnjnQtEv1MFtK"
| ai
model="gpt-oss-20b"
mode=per_row
input="host.name,user.name,message"
user_message="For each row return risk, type, reason"
output="risk,type,reason"

Result (rows enriched with new fields):

[
{
"host.name": "srv-1",
"user.name": "admin",
"message": "wmic remote process create",
"risk": "high",
"type": "lateral_movement",
"reason": "Remote process execution via WMI."
},
{
"host.name": "srv-2",
"user.name": "svc",
"message": "normal login",
"risk": "low",
"type": "benign_activity",
"reason": "No signs of attack detected."
}
]

Example 3​

Example of using a preset while overriding user_message.

source soc_events_prod
| ai preset=my_preset output="summary" mode=summary user_message="How to fix the problem"

Example 4​

With explicit limits.

source k8s_otel_traces
| ai model="gpt-oss-20b" output="summary" max_prompt_tokens=5000 max_tokens=700 timeout=600000