# AI Prompt Step

> Make a single AI call inside a workflow. Write instructions, reference the data you want the model to see, and get a result downstream steps can use.

The AI Prompt step makes one AI call and returns the result to the steps that follow. It is the building block for classification, summarisation, extraction, translation, and anything else that fits in a single call.

**It runs on Glow's managed infrastructure.** There is no API key to configure, no provider to connect and no model to choose: write the instructions and run it. Usage is billed through your Glow plan.

For tasks that need tools, multiple reasoning steps, or memory, use the [AI Agent](/build/ai-features/ai-agent) step instead. To pull several values out of one messy text without writing a prompt, [AI Data Transform](/build/ai-features/ai-transform) does it with one instruction per value.

> **The model sees only what you write.** Previous steps are never passed to the
> AI automatically. If you do not reference a value in your instructions, it
> does not exist as far as the model is concerned.

## Setting it up

### Add it to the canvas
Press **a+p**, or drag **AI Prompt** from the **AI** section of the dock.

### Write the instructions

Select the step to open the App drawer and fill in the **Instructions** field.

### The fields

| Field                 | Type    | Description                                                                                           |
| --------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| **Instructions**      | String  | What the AI should do, including the data it should work with. Required.                              |
| **Response shape**    | Editor  | Off by default. Name the fields you want back and every run answers with the same fields.             |
| **Parse JSON result** | Boolean | Off by default. Turn it on when your instructions ask for JSON but you have not set a Response shape. |

**Response shape** sits in the main form, directly below Instructions. **Parse JSON result** sits under **Optional Props**. There is no model dropdown. See [Models](/build/ai-features/supported-models) for how the AI steps differ on this.

## Getting the same fields every time

A model left to itself will phrase its answer differently from run to run, which is fine for a summary and a problem for anything a later step reads. **Response shape** fixes that: you describe the structure you want, and the model is held to it while it writes rather than checked afterwards.

Turning it on opens the shape editor. In the **Fields** view, add one row per value you want back. Name each field, pick its kind, and mark it required or optional. The kinds are text, number, yes/no, list, and group, where a group holds nested fields of its own.

If the step has already run successfully, Glow reads the last answer and offers its fields as a starting point. Click **Use this** to accept them, or **Set it up myself** to start from a blank shape.

Already have a schema written down? The **JSON** tab takes a JSON Schema directly. There, a shape for a support ticket might read:

```json
{
  "type": "object",
  "properties": {
    "category": { "type": "string" },
    "urgency": { "type": "string" },
    "needsHuman": { "type": "boolean" }
  },
  "required": ["category", "urgency"]
}
```

Downstream steps then read `{{ 2.result.category }}` and `{{ 2.result.urgency }}` knowing both are always there.

Turning Response shape off keeps the shape you built. Turn it back on and it is there again, so you can pause enforcement without rebuilding anything.

**If the answer does not match the shape, the step fails** and says which part was wrong. A malformed answer stops the run rather than travelling on as something a later step misreads.

**Ask the AI to fix a wrong shape** changes that. Turn it on and a mismatched answer is sent back once, with the problem described, and the corrected answer is used. It costs one extra AI call on the runs that need it, so the better first move is to describe the shape in your instructions as well. The retry is then a safety net rather than part of the normal path.

## Referencing data

Include data from earlier steps by referencing their **step number** inside the instructions.

```text
Classify the following support ticket into one of these categories:
billing, technical, account, other.

Ticket subject: {{ 1.subject }}
Ticket body: {{ 1.content }}

Respond with only the category name.
```

To pass a step's entire output, reference the step number alone:

```text
Summarize this email: {{ 3 }}
```

> **Insert references with the data picker rather than typing them.** The path
> depends on the step: an HTTP Request puts its response under `ret`, so it is
> `{{ 3.ret.email }}` and not `{{ 3.email }}`. The picker fills in whatever is
> correct for that step and shows you the real value beside it.
>
> A reference that finds nothing (wrong path or wrong step number) stops the
> run there and names itself in the error, rather than sending the model a blank.
> Run the step once and read the Executions tab to confirm the real path before
> you build on it.

Full syntax is documented in [Variable Reference Syntax](/reference/variable-syntax).

## What it passes on

**`result` keeps the shape of what the AI returned.** Ask for a sentence and it
holds a sentence; ask for a list of objects and it holds a list of objects, ready
for a later step to walk into or loop over.

```text
Extract the following fields from the invoice text below. Return valid JSON
with keys: vendor_name, invoice_number, date, total_amount.

Invoice text:
{{ 1.invoice_text }}
```

A run asking for a joke comes back as:

```json
{ "result": "Why don't skeletons fight each other? They don't have the guts." }
```

and one asking for three people as:

```json
{
  "result": [
    { "name": "Ann", "city": "Prague" },
    { "name": "Bob", "city": "Brno" }
  ]
}
```

so `{{ 2.result.vendor_name }}` and `{{ 2.result.0.name }}` both work when the
answer has that shape.

**When the shape matters, set Response shape.** The answer then always has the
fields you named, and later steps can read them with no parsing step. **Parse
JSON result** covers the other case: your instructions ask for JSON but you have
not set a shape. It tells the model to answer in clean JSON with no markdown
around it, and parses the text so later steps can select individual fields.

> **The AI Agent returns the same `result`, plus its reasoning.** Swapping one
> step for the other does not break `{{ N.result }}`. The agent also
> offers `{{ N.thoughts }}`, which the AI Prompt step has no equivalent of.

> Ask for the exact keys you want and state that the response must be valid
> JSON. Models follow an explicit schema far more reliably than an implied one.

## Limits

### Missing input

If a referenced value is empty, that part of the prompt arrives blank and the model works with what remains. That usually produces a confident but wrong answer. Add a [Condition](/build/action-steps/conditions) step before the AI Prompt to check that required data is present.

### The answer arrives in the wrong shape

Left to itself a model phrases things differently from one run to the next. Where the shape matters, set **Response shape** and the answer is held to it: see [Getting the same fields every time](#getting-the-same-fields-every-time).

### High-volume runs

Every run of the workflow is a model call. Before scaling a workflow to thousands of daily runs, check the effect on both cost and execution time, and see [System Limits](/reference/system-limits) for the ceilings that apply to your plan.

## Examples to copy

  
    A webhook receives support tickets. The AI Prompt step classifies each one, and a [Switch](/build/action-steps/switch) step routes it to the right queue.

    ```text
    You are a support ticket classifier. Read the ticket below and respond
    with exactly one category: billing, technical, account, or other.

    Subject: {{ 1.subject }}
    Body: {{ 1.content }}
    ```

  
  
    A [Scheduler](/build/triggers/scheduler) trigger runs each morning and fetches unread email. The AI Prompt step summarizes each one for a Slack briefing.

    ```text
    Summarize the following email in two sentences. Focus on action items
    and key decisions.

    From: {{ 2.from }}
    Subject: {{ 2.subject }}
    Body: {{ 2.body }}
    ```

  
  
    A webhook receives free-text invoices. The step extracts structured fields for a database write.

    ```text
    Extract the following fields from the invoice text below. Return valid
    JSON with keys: vendor_name, invoice_number, date, total_amount.

    Invoice text:
    {{ 1.invoice_text }}
    ```

    Set **Response shape** with those four fields so the next step can map each one individually.

  

## What's Next?

- Need tools, memory, or multi-step reasoning? Use the [AI Agent](/build/ai-features/ai-agent) step.
- Look up reference syntax in [Variable Reference Syntax](/reference/variable-syntax).
