Zebflow Docs
ai.text.generate
Zebflow Docs

ai.text.generate

Asks a language model for text, optionally letting it call the project's function pipelines as tools

ai.text.generate --provider openai|openrouter --credential TEXT --prompt TEXT [--system-prompt TEXT] [--tool TEXT…] [--budget N] [--schema JSON] [--max-repairs N] [--verify TEXT] [--model TEXT] [--answer-only] [--option KEY=TEXT…] → text

Asks a language model for text, optionally letting it call the project's function pipelines as tools. One model loop: the prompt goes to the model with the named tools; each tool call the model makes is run and fed back; it stops when the model answers with text or the budget is spent. With no --tool it is one call — classify, extract, summarise, draft. With --schema the answer is parsed as JSON, checked, repaired once on failure and returned as text.data. Tools are the project's function pipelines, named by --tool; nothing is offered unless named. Adds text: { value, verified, data, … } and keeps the payload. Step signals (thinking, tool_call, tool_result, final) stream over SSE when the webhook is called with Accept: text/event-stream. Private and loopback addresses are refused; a self-hosted model on the project's own network needs Allow Private Host set to true and its host in Private Hosts (allow_private, allowed_hosts) on the credential.

Per provider (--provider picks one; each line is generated from its profile):

ai.text.generate --provider openai --credential TEXT --prompt TEXT [--system-prompt TEXT] [--tool TEXT…] [--budget N] [--schema JSON] [--max-repairs N] [--verify TEXT] [--model TEXT] [--answer-only] → textai.text.generate --provider openrouter --credential TEXT --prompt TEXT [--system-prompt TEXT] [--tool TEXT…] [--budget N] [--schema JSON] [--max-repairs N] [--verify TEXT] [--model TEXT] [--answer-only] → text
  • openai — --credential of kind openai
  • openrouter — --credential of kind openrouter

Flags

  • --provider (required): Who answers: openai (Responses API) or openrouter (Chat Completions). Literal, never {{ }}.
  • --credential (required): Credential holding the provider's key: kind openai for openai, openrouter for openrouter. The only source of the LLM key.
  • --prompt (required): The prompt — literal or {{ expr }}; or write it after --.
  • --system-prompt: Standing instructions for every call — literal or {{ expr }}.
  • --tool: A function pipeline the model may call, by name — repeat for several. Nothing is offered unless named; with no tool the node is one call.
  • --budget: Maximum model calls before the loop stops (default 10). Repairs count.
  • --schema: JSON Schema (type, required, properties, items, enum, minItems, minLength) the answer must satisfy; the parsed answer is text.data. Quote with single quotes in the DSL.
  • --max-repairs: How many times a failed --schema/--verify is fed back for another attempt (default 1).
  • --verify: A function pipeline that checks the answer: receives {candidate, goal}, returns {pass, reason}. Runs after the schema check.
  • --model: Model id, overriding the credential's default.
  • --answer-only: Answer only value, verified and data: no step log, tool events or metrics.
  • --option: A setting of the chosen provider, key=value, repeated. The keys and their types are the provider's profile; an unknown key is refused.

Examples

One call: summarise a submission

| ai.text.generate --provider openai --credential openai_main --system-prompt "You write one plain sentence." --prompt "Summarise: {{ $trigger.body.text }}"

No --tool, so one round trip. The answer is added under text and the rest of the payload is kept. The credential is created by the owner in Studio → Credentials.

Input:

json
{  "webhook": {    "body": {      "text": "Our clinic moved to 12 High St and now opens Saturdays 9–1."    }  }}

It answers:

json
{  "webhook": {    "body": {      "text": "Our clinic moved to 12 High St and now opens Saturdays 9–1."    }  },  "text": {    "value": "The clinic has moved to 12 High St and now opens on Saturday mornings.",    "verified": true,    "tools_called": [],    "iterations": 1,    "budget_exhausted": false  }}

One call: classify to JSON

| ai.text.generate --provider openai --credential openai_main --answer-only --schema '{"type":"object","required":["sentiment"],"properties":{"sentiment":{"enum":["positive","neutral","negative"]}}}' -- Classify this review: {{ $trigger.body.review }}

text.data is the parsed, checked answer; branch on it with logic.if --when "$nodes.a.text.data.sentiment == 'negative'". A failed check is fed back once (--max-repairs).

Input:

json
{  "webhook": {    "body": {      "review": "Booking was easy but the wait was long."    }  }}

It answers:

json
{  "webhook": {    "body": {      "review": "Booking was easy but the wait was long."    }  },  "text": {    "value": "{\"sentiment\":\"neutral\"}",    "data": {      "sentiment": "neutral"    },    "verified": true  }}

Tools: answer from the project's data

| ai.text.generate --provider openrouter --credential router_main --tool lookup-order --budget 6 --system-prompt "You answer questions about orders. Use the tools; never guess." --prompt "{{ $trigger.body.message }}"

lookup-order is a function pipeline (trigger.function) in this project; the model calls it with the arguments its input schema declares.

Input:

json
{  "webhook": {    "body": {      "message": "Where is order o_91?"    }  }}

It answers:

json
{  "webhook": {    "body": {      "message": "Where is order o_91?"    }  },  "text": {    "value": "Order o_91 shipped yesterday and arrives Friday.",    "verified": true,    "tools_called": [      "lookup-order"    ],    "iterations": 2,    "budget_exhausted": false  }}