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).
fieldstringyes—Input UTF-8 column to send. Rows must be non-null.
target_fieldstringnoresponseName of the appended completion column.
system_promptstringno—System message prepended to each request.
prompt_templatestringno—User-message template; {{value}} is replaced with the row text. 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.
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.
note

Each row is one request (the chat protocol has no batch form). The first row failure short-circuits the batch — in-flight requests are dropped rather than awaited — and the batch flows to error_output as a whole. The processor does not retry LLM calls; size concurrency and upstream batches to stay within rate limits. Requests to loopback endpoints always bypass the system proxy.

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