Skip to main content
Version: Next
llmINPUTBUFFERPROCESSOROUTPUT

LLM

The llm processor sends each row of a text column to an OpenAI-compatible chat completions API and appends the completion as a Utf8 column. Use it for in-stream summarization, translation, rewriting, classification, or structured extraction. Any endpoint that speaks the OpenAI /chat/completions protocol works: OpenAI, Azure OpenAI (via headers), vLLM, or Ollama gateways.

It pairs naturally with SQL (prepare the prompt column first) and the embedding processor (embed what the model produced).

Configuration​

FieldTypeRequiredDefaultDescription
typestringyes—llm
api_basestringyes—API base URL; the request path is {api_base}/chat/completions.
modelstringyes—Chat model name (e.g. gpt-4o-mini).
fieldstringconditional—Input UTF-8 column to send. Rows must be non-null. Required unless prompt_template references at least one column via {{column_name}}.
target_fieldstringnoresponseName of the appended completion column.
system_promptstringno—System message prepended to each request.
prompt_templatestringno—User-message template supporting {{value}} (resolved to field) and {{column_name}} placeholders for any column in the batch. Non-string columns are formatted as text; NULLs render as empty string. When omitted the row text is the user message.
temperaturenumberno—Sampling temperature; omitted from the request when unset.
max_tokensintegerno—Completion token cap; omitted from the request when unset.
concurrencyintegerno4Maximum in-flight requests; results are always filled back in row order.
api_keystringno—Sent as Authorization: Bearer. Supports secret references.
timeout_msintegerno30000HTTP request timeout.
retry_countintegerno3Retries for transient failures (429/5xx/transport). 0 disables retrying.
headersmapno—Extra HTTP headers (e.g. Azure's api-key).
streambooleannofalseRequest SSE streaming and assemble the deltas into the row's final completion text. Useful behind providers or gateways that time out non-streaming long completions. The processor still emits one complete text per row.
toolsarrayno—OpenAI tools definition passed through verbatim for function calling.
tool_calls_columnstringno—When set, appends this column with the response's tool calls as JSON text (empty string when there are none). Streamed tool-call deltas are merged by index.
response_formatobjectno—OpenAI response_format specification passed through verbatim for structured output.
note

Each row is one request (the chat protocol has no batch form). Without an on_error policy (or with fail), the first deterministic row failure (4xx, parse errors — or retries exhausted) short-circuits the batch — in-flight requests are dropped rather than awaited — and the batch flows to error_output as a whole. Under on_error: dlq/drop/error_column the processor implements the row-error protocol: every row is attempted and failing rows are marked with their reason (__arkflow_row_error) instead of failing the batch — the kernel routes or annotates them per the policy. Configuration-level failures (the field column missing or not UTF-8) fail the batch under every policy. Transient failures retry per retry_count (default 3; retry_count: 0 disables retrying); size concurrency and upstream batches to stay within rate limits. Requests to loopback endpoints always bypass the system proxy.

Transient HTTP failures (429, 5xx, connection errors) are retried with capped exponential backoff (retry_count, default 3); 4xx rejections and parse/validation failures fail immediately without retrying.

Example​

- type: "llm"
api_base: "https://api.openai.com/v1"
model: "gpt-4o-mini"
api_key: "${env:OPENAI_API_KEY:-}"
field: "text"
system_prompt: "Translate the text to French. Reply with the translation only."
prompt_template: "{{value}}"
concurrency: 4

Complete Pipeline Example​

logging:
level: info

streams:
- id: support-tagger
input:
type: memory
pipeline:
thread_num: 4
processors:
- type: json_to_arrow
- type: llm
api_base: "https://api.openai.com/v1"
model: "gpt-4o-mini"
api_key: "${env:OPENAI_API_KEY:-}"
field: "text"
system_prompt: "Classify the support ticket with a single word: billing, bug, or feature."
target_field: "category"
temperature: 0
output:
type: stdout