How-to guide
Use LLM activities
Add summarising, classification, structured decisions, image analysis and retrieval-augmented answers to workflow steps.
Prerequisites
- An AI assistant or provider key configured for the workflow server
Kiwi Flow has four LLM activity types. Calls go through a provider-agnostic abstraction, so you can switch between OpenAI, Azure OpenAI, Anthropic and Ollama (self-hosted) without changing workflow logic.
| Type | Use it for |
|---|---|
llm_text |
Generate or transform text: summarise, translate, extract, classify, sentiment, rewrite, question answering, or a fully custom prompt |
llm_decision |
Return a structured JSON decision validated against an output schema, typically followed by a switch |
llm_image |
Analyse an image (base64 or public URL) with a multimodal model |
llm_rag |
Answer a question from your own documents, with retrieved context and sources |
Text operations#
llm_text builds its prompts for you when you pick a built-in operation. The prompt and systemPrompt fields apply only to custom. If operation is absent, the activity behaves as custom.
| Operation | Primary input | Key operationConfig settings |
|---|---|---|
custom |
prompt |
systemPrompt (optional) |
summarize |
content |
maxCharacters (default 500), format (paragraph, bullets, tldr), language |
translate |
content |
targetLanguage (required), preserveFormatting (default true) |
extract |
content |
fields (array of {name,type,description}), outputFormat (json or text) |
classify |
content |
categories (required), allowMultiple, confidenceThreshold |
sentiment |
content |
scale (positive-negative, 1-5, 1-10), includeReason |
rewrite |
content |
tone (formal, casual, technical, friendly, concise), maxCharacters |
qa |
the input named by contextField |
question (required), contextField (default content) |
{
"id": "a_summary",
"type": "llm_text",
"llm_text": {
"provider": "anthropic",
"model": "<model-id>",
"operation": "summarize",
"operationConfig": { "maxCharacters": 300, "format": "bullets", "language": "english" },
"temperature": 0.3,
"maxTokens": 1024
},
"inputs": [ { "name": "content", "from": "a_prev.output.body" } ],
"outputs": [ { "name": "summary", "from": "output.text" } ]
}
Besides output.text, extract adds each parsed field as a named output (when outputFormat is json), classify adds category and categories, and sentiment adds sentiment and an optional reason.
AI-driven routing#
llm_decision asks the model for JSON and validates it against outputSchema before mapping it to outputs. Pair it with switch:
{
"id": "a_llm",
"type": "llm_decision",
"llm_decision": {
"provider": "anthropic",
"model": "<model-id>",
"outputSchema": { "decision": "string", "riskLevel": "string", "confidence": "number" },
"temperature": 0.2,
"maxTokens": 512
},
"inputs": [ { "name": "prompt", "value": "Given orderValue={{inputs.orderValue}}, classify the risk. Return JSON." } ],
"outputs": [
{ "name": "decision", "from": "output.decision" },
{ "name": "riskLevel", "from": "output.riskLevel" }
],
"next": "a_risk_switch"
}
Then route on a_llm.output.decision with a switch. See Branch, loop and run in parallel.
Retrieval-augmented answers#
llm_rag searches a vector corpus (set with corpusId, topK, minScore in its config block, or supply documents at run time) and returns answer, the retrieved context, sources and chunkCount. When PostgreSQL is the platform database, embeddings are stored with pgvector; other database engines can use an alternative vector store.
Providers and keys#
Supported providers: openai, azure_openai, anthropic and ollama. You bring your own API key. Register provider configurations as AI assistants:
kiwi flow ai-assistant-set --name default --provider Anthropic --model <model-id> --api-key "<provider-key>"
kiwi flow ai-assistant-test --name default
kiwi flow ai-assistant-default --name default
Azure OpenAI and self-hosted models also need --endpoint (and --deployment for Azure).
Tip
Keep temperature low (around 0.2 to 0.3) for decisions and extraction, where you want consistent, structured output.
Expected result
- LLM output is validated and mapped into workflow outputs, and drives routing where needed