> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracecat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI action

> Use `ai.action` to run a single LLM call inside a Tracecat workflow: pick a model, pass instructions and inputs, and shape structured output for downstream actions.

Use `ai.action` when you only need a prompt and an output. It runs one model call and does not let the model call tools.

## Capabilities

* Pass task instructions in `instructions` and task data in `user_prompt`.
* Use `output_type` when you need a string, list, or JSON-shaped response for downstream actions.
* Tune provider-specific behavior with `model_settings`.

## Structured outputs

Use `output_type` when a downstream action needs a predictable shape.

* Use a scalar such as `str` or `int` for simple classification or routing.
* Use a JSON schema object when you need named fields.
* Tracecat parses valid JSON before storing it in the action result.

## Reference

### `ai.action`

Call an LLM with a given prompt and model (no tools).

#### Inputs

<ParamField path="model_name" type="string" required>
  Name of the model to use.
</ParamField>

<ParamField path="model_provider" type="string" required>
  Provider of the model to use.
</ParamField>

<ParamField path="user_prompt" type="string" required>
  User prompt to the agent.
</ParamField>

<ParamField path="base_url" type="string | null">
  Base URL of the model to use.

  Default: `null`.
</ParamField>

<ParamField path="instructions" type="string | null">
  Instructions for the agent.

  Default: `null`.
</ParamField>

<ParamField path="max_requests" type="integer">
  Maximum number of requests for the agent.

  Default: `45`.
</ParamField>

<ParamField path="model_settings" type="object | null">
  Model settings for the agent.

  Default: `null`.
</ParamField>

<ParamField path="output_type" type="string | object | null">
  Output type for agent responses. Select from a list of supported types or provide a JSONSchema.

  Default: `null`.
</ParamField>

<ParamField path="retries" type="integer">
  Number of retries for the agent.

  Default: `3`.
</ParamField>

#### Examples

**Extract structured fields from an alert**

```yaml theme={null}
- ref: extract_alert
  action: ai.action
  args:
    model_name: gpt-4.1-mini
    model_provider: openai
    instructions: |
      Extract the alert into the requested schema.
      Use null for fields that are missing.
    user_prompt: |
      Parse this alert and normalize the key fields:

      ${{ TRIGGER.raw_alert }}
    output_type:
      type: object
      properties:
        severity:
          type: string
        user:
          type:
            - string
            - "null"
        src_ip:
          type:
            - string
            - "null"
        needs_escalation:
          type: boolean
      required:
        - severity
        - needs_escalation
```

**Classify an email triage decision**

```yaml theme={null}
- ref: classify_email
  action: ai.action
  args:
    model_name: claude-3-5-sonnet-latest
    model_provider: anthropic
    instructions: |
      Return one of: phishing, benign, spam, unknown.
    user_prompt: |
      Subject: ${{ TRIGGER.subject }}
      Sender: ${{ TRIGGER.sender }}
      Body:
      ${{ TRIGGER.body }}
    output_type:
      type: string
      enum:
        - phishing
        - benign
        - spam
        - unknown
```
