Skip to content

LLM Completion

Send a prompt or message list to a large language model with action: chat.completion.

The response is written to stdout, so it can be viewed in the run log or captured for later steps.

Basic Usage

Use prompt for a single user message:

yaml
steps:
  - id: summarize
    action: chat.completion
    with:
      provider: openai
      model: gpt-4o
      prompt: |
        Summarize the main causes of database connection exhaustion.
    output: SUMMARY

SUMMARY is a flat output variable. A dependent step can read it as ${SUMMARY}. See Outputs & Routing for downstream steps, artifacts, and switch-style routing.

Use messages when the request needs an explicit system prompt or conversation:

yaml
steps:
  - id: diagnose
    action: chat.completion
    with:
      provider: anthropic
      model: claude-sonnet-4-6
      system: |
        Answer as a concise operations runbook author.
      messages:
        - role: user
          content: |
            Explain how to diagnose a saturated connection pool.

Specify either prompt or messages. prompt is converted to one user message. If both fields are present, prompt takes precedence. Message roles can be system, user, or assistant.

Configuration

All action-specific fields belong under with.

FieldTypeDefaultDescription
promptstringA non-empty user prompt. Required when messages is omitted.
messagesarrayA non-empty list of {role, content} messages. Required when prompt is omitted.
providerstringinheritedLLM provider. Required for a string model unless inherited; omit it when every fallback model entry has its own provider.
modelstring or arrayinheritedModel identifier, or an ordered list of model configurations for fallback. Inherited only when the action sets no LLM configuration fields.
systemstringDefault system prompt. An explicit system message in messages takes precedence.
temperaturenumberprovider defaultSampling randomness from 0.0 to 2.0.
max_tokensintegerprovider defaultMaximum number of tokens to generate.
top_pnumberprovider defaultNucleus sampling value from 0.0 to 1.0.
base_urlstringprovider defaultBase URL for a custom or OpenAI-compatible endpoint.
api_key_namestringprovider defaultEnvironment variable that contains the API key.
streambooleantrueStream response tokens to stdout as they arrive.
thinkingobjectdisabledProvider-specific extended reasoning.
toolsarrayDAG names exposed to the model as callable tools.
max_tool_iterationsinteger10Maximum tool-calling rounds.
web_searchobjectdisabledBuilt-in web-search integration settings.

messages[].content, system, and base_url support scoped value references such as ${params.TOPIC} and ${env.LLM_BASE_URL}.

Security

Values registered as Dagu secrets are masked before messages are sent to the provider. The run's saved session retains the resolved message content, so avoid placing unnecessary secrets in prompts and restrict access to run history.

Next Steps

Released under the MIT License.