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

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Journey AI node

> Run an OpenAI or Anthropic model prompt in a journey and store its structured output under data.ai_result. Runs on AI credits, in the US datacenter only.

AI nodes run a large language model prompt as part of a journey. Courier sends the prompt and the run's context to the model you select.

Courier parses the response into structured output and adds it to the journey context under `data.ai_result`.

Downstream nodes use that output to make decisions, personalize messages, or update user data.

**AI nodes run on [AI credits](#billing).** A run fails at the AI node when the workspace has none. Add credits in [Settings → Billing](https://app.courier.com/settings/billing).

AI nodes run in the US datacenter only. In the [EU datacenter](https://www.courier.com/docs/workspaces/datacenters.md), creating, replacing, or publishing a journey with an AI node fails with `AI steps aren't available in this region yet`.

## Configuration

Click the AI node on the canvas to open the summary panel, then click **Configure** to open the full configuration drawer.

![The Configure AI drawer with Claude Sonnet 4.6 selected, web search off, a prompt using data variables, and a four-field output schema](https://mintcdn.com/courier-4f1f25dc/A-IH_41Pkuff3UAy/assets/ai-node-edit-drawer.webp?fit=max\&auto=format\&n=A-IH_41Pkuff3UAy\&q=85\&s=85b402f156dc5667b28a1b9f6bd338b2)

AI node configuration drawer with model selector, web search toggle, prompt, and output schema

### AI model

Choose the model that fits what the AI node needs to do. Courier supports models from OpenAI and Anthropic, so each node can balance speed, cost, and output quality.

Use smaller models for predictable structured tasks: classifying users, extracting fields, scoring engagement, or returning simple JSON. Use larger models when the prompt needs more context, nuanced reasoning, or higher-quality generated copy.

Available models:

| Provider | Model | Model ID |
| - | - | - |
| Anthropic | Claude Fable 5.2 | `claude-fable-5-2` |
| Anthropic | Claude Opus 5.5 | `claude-opus-5-5` |
| Anthropic | Claude Sonnet 5.5 | `claude-sonnet-5-5` |
| Anthropic | Claude Haiku 5.5 | `claude-haiku-5-5` |
| OpenAI | GPT-6 Astra | `gpt-6-astra` |
| OpenAI | GPT-5.5 | `gpt-5.5` |
| OpenAI | GPT-5.4 | `gpt-5.4` |
| OpenAI | GPT-6.1 Sol | `gpt-6.1-sol` |
| OpenAI | GPT-6.1 Terra | `gpt-6.1-terra` |
| OpenAI | GPT-5.4 Mini | `gpt-5.4-mini` |
| OpenAI | GPT-5.4 Nano | `gpt-5.4-nano` |
| OpenAI | GPT-6 Luna | `gpt-6-luna` |

When you create or replace a journey through the API, set the AI node's `model` to the model ID and give it a `user_prompt`. Both are required, so a missing or blank one fails with `AI step needs a model` or `AI step needs a prompt`. An ID that isn't in the table fails with `unknown model`, followed by the list of valid IDs. Retired model IDs keep working: Courier runs them on their successor model.

See [Billing](#billing) for credit costs, token overages, and web search pricing.

### Web search

Toggle web search on when the prompt needs current information the journey context doesn't have. The model can then query the internet before generating its structured response.

Web search is available for Anthropic models only. Each invocation with web search enabled costs an additional **2 credits**. Search results also count as input tokens, along with the prompt, output schema, journey context, and resolved variables. If the total input exceeds **3,072 tokens**, input token overage applies.

### Prompt

Write a natural-language prompt describing what you want the model to do. The prompt field supports `{{variable}}` interpolation. Type `{{` to see available fields from the trigger schema, profile, or upstream fetch responses.

For the onboarding nudge example below, the prompt might be:

```text theme={null}
You are a product growth assistant. Based on this user's profile and activity, write a personalized onboarding nudge that encourages them to try the next feature most relevant to their use case.

Rules:
- subject_line should be under 60 characters, personalized, and action-oriented
- body_copy should be 1-2 sentences, friendly, and reference what they've already done
- recommended_feature must be exactly one of: templates, automations, integrations, analytics
- tone must be exactly one of: encouraging, celebratory, urgent

User: {{data.user_name}}
Plan: {{data.plan_name}}
Features used so far: {{data.features_used}}
Days since signup: {{data.days_since_signup}}
```

A token counter in the top-right of the drawer shows prompt + schema size in real time. Most AI node runs stay within the included token limit. Input token overage usually comes from variables, fetch responses, or web search results that add large amounts of text.

### Output schema

The output schema defines the structure of the model's response. Define it in two modes:

**Form mode** (default): Add fields with a name and type (string, number, integer, or boolean). Optionally add a description telling the model what the field should contain.

**JSON mode**: Write a JSON Schema directly. Use this for more complex schemas or when pasting from an existing definition.

For the onboarding nudge example, the form-mode schema would be:

| Field | Type | Description |
| - | - | - |
| `subject_line` | string | Personalized email subject under 60 characters |
| `body_copy` | string | 1-2 sentence nudge referencing the user's activity |
| `recommended_feature` | string | One of: templates, automations, integrations, analytics |
| `tone` | string | One of: encouraging, celebratory, urgent |

The model's response is parsed as JSON and stored in the journey context under `data.ai_result`. Downstream nodes read each field under that key:

* In [branch conditions](https://www.courier.com/docs/journeys/nodes/branch.md): select `data.ai_result.tone` or `data.ai_result.recommended_feature` as the field
* In [journey templates](https://www.courier.com/docs/journeys/build.md): use `{{ai_result.subject_line}}` or `{{ai_result.body_copy}}`

**A second AI node overwrites `data.ai_result`.** Read the first node's output before the run reaches the next one.

### Conditions

AI nodes support optional [conditions](https://www.courier.com/docs/journeys/nodes/branch.md). If they aren't met when the run reaches the node, it's skipped and no credits are consumed.

## Testing

Click **Test** in the configuration drawer to open the test panel. Run the prompt against the selected model with sample variable values and see the structured response before publishing the journey.

![The Test AI Node drawer with sample variable values, the prompt and output schema, and the structured JSON result from Run test](https://mintcdn.com/courier-4f1f25dc/A-IH_41Pkuff3UAy/assets/ai-node-test-drawer.webp?fit=max\&auto=format\&n=A-IH_41Pkuff3UAy\&q=85\&s=401a429e6bcf8b28fa528d4c6ac55459)

Test drawer showing prompt, output schema, and structured test result

The test result shows the parsed JSON output on the right, or an error message if the request failed.

> [!WARNING]
>
> A test run is billed like a real one. It calls the same model and deducts the same credits, so iterating on a prompt with an expensive model adds up.

## Example: personalized onboarding nudge

A journey that generates tailored onboarding messages from each user's activity:

![Journey canvas: trigger, Fetch Data, AI, then a Branch whose Urgent path sends push and Celebratory and Default paths send email](https://mintcdn.com/courier-4f1f25dc/A-IH_41Pkuff3UAy/assets/ai-node-example-journey.webp?fit=max\&auto=format\&n=A-IH_41Pkuff3UAy\&q=85\&s=847711bd514d06905d48424df7d62342)

Onboarding nudge journey: API trigger → Fetch activity → AI generates personalized copy → branch on tone → send via the right channel

1. **Trigger**: Fires on day 3 after signup. The trigger schema includes `user_name`, `plan_name`, `features_used`, and `days_since_signup`.
2. **Fetch Data**: Pulls the user's recent activity summary from your application API.
3. **AI node**: Given the user's profile and activity, generates a personalized nudge with `subject_line`, `body_copy`, `recommended_feature`, and `tone`. Model: Claude Sonnet 5.5 (1.75 credits per run).
4. **Branch**: Routes based on `data.ai_result.tone`:
   * Path "Celebratory": user has been active → sends a congratulatory email with `{{ai_result.subject_line}}` and `{{ai_result.body_copy}}`.
   * Path "Urgent": user hasn't engaged → sends a push notification to re-engage.
   * Default: sends a standard onboarding email with the AI-generated copy.

## Common patterns

**Score and classify users**: Feed product usage, behavior, and profile data into the LLM. Route the journey based on risk level, intent, engagement, or any structured category the model returns.

**Generate personalized notifications**: Give the model your journey context and get back tailored subject lines, body copy, and recommended actions. Personalized content for every recipient without dozens of template variants.

**Enrich user profiles**: Classify users into personas, derive lifecycle stage, or generate account summaries. Persist outputs to the profile so every future journey starts with richer context.

**Structured output for downstream logic**: Define an output schema with field names, types, and enums. The LLM returns structured JSON that branch conditions, send nodes, and downstream integrations can act on directly.

## Debugging AI nodes

Open the run in [journey logs](https://www.courier.com/docs/monitor/logs.md#read-a-run) and click the AI node step to see:

* The model used and whether web search was enabled
* The resolved prompt (with variables substituted)
* The output schema that was sent to the model
* The structured JSON response
* Token usage (input and output token counts)

**A failed AI node stops the run.** The step and the run both end in `error`, and no node after the AI node runs. The step's error message names the cause:

| Message | Cause |
| :- | :- |
| `This workspace has no AI credits. Add credits in Settings → Billing.` | The workspace has no AI credits |
| `Model "<id>" isn't supported.` | The node's model ID isn't one Courier runs |
| `AI step timed out after 15 minutes` | The model didn't answer within 15 minutes. A late answer is ignored and doesn't resume the run. |
| `AI step failed: <message>` | The model provider returned an error |
| `AI steps aren't available in this region yet` | The workspace is in the EU datacenter |

Read the message on the AI step in [journey logs](https://www.courier.com/docs/monitor/logs.md#read-a-run), or in the step's `error.message` from [`GET /journeys/runs/{run_id}/steps`](https://www.courier.com/docs/api-reference/journeys/list-steps-for-a-journey-run).

## Billing

On the Developer plan, AI nodes can't be placed on the canvas, and credit packs can't be bought.

Each AI node invocation consumes credits based on the selected model. Credits are billed at **100 credits per \$1** and bought as packs in the console, separately from your send bill. Auto top-up charges your card for another pack when the balance falls below a threshold, 100 credits by default.

| Provider | Model | Credits per invocation |
| - | - | -: |
| Anthropic | Claude Fable 5.2 | 7 |
| Anthropic | Claude Opus 5.5 | 3.5 |
| Anthropic | Claude Sonnet 5.5 | 1.75 |
| Anthropic | Claude Haiku 5.5 | 0.1 |
| OpenAI | GPT-6 Astra | 9 |
| OpenAI | GPT-5.5 | 5 |
| OpenAI | GPT-5.4 | 2.5 |
| OpenAI | GPT-6.1 Sol | 1.75 |
| OpenAI | GPT-6.1 Terra | 1 |
| OpenAI | GPT-5.4 Mini | 0.75 |
| OpenAI | GPT-5.4 Nano | 0.2 |
| OpenAI | GPT-6 Luna | 0.1 |

The values above are base costs per invocation. Each invocation includes up to **3,072 input tokens** and **1,000 output tokens**. Most AI node runs stay within these included limits.

Input tokens cover everything sent to the model: the prompt, output schema, journey context, resolved variables, upstream fetch responses, and web search results. Input token overage applies when the node sends a large amount of text, such as long variables, large fetch responses, or web search results.

Output tokens are generated by the model response. Output token overage applies only when the model response exceeds 1,000 tokens. Control output length through the prompt and output schema.

| Provider | Model | Input token overage credits / 1K tokens | Output token overage credits / 1K tokens |
| - | - | -: | -: |
| Anthropic | Claude Fable 5.2 | 1.000 | 5.000 |
| Anthropic | Claude Opus 5.5 | 0.500 | 2.500 |
| Anthropic | Claude Sonnet 5.5 | 0.250 | 1.250 |
| Anthropic | Claude Haiku 5.5 | 0.013 | 0.063 |
| OpenAI | GPT-6 Astra | 1.250 | 6.250 |
| OpenAI | GPT-5.5 | 0.625 | 3.750 |
| OpenAI | GPT-5.4 | 0.313 | 1.875 |
| OpenAI | GPT-6.1 Sol | 0.250 | 1.250 |
| OpenAI | GPT-6.1 Terra | 0.125 | 0.625 |
| OpenAI | GPT-5.4 Mini | 0.094 | 0.563 |
| OpenAI | GPT-5.4 Nano | 0.025 | 0.156 |
| OpenAI | GPT-6 Luna | 0.013 | 0.063 |

Web search is available for Anthropic models only. When enabled, each invocation costs an additional **2 credits**. Search results also count as input tokens, so web search can push the total past 3,072 tokens and trigger input token overage.
