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

# Prompt Chaining Workflow

> This example demonstrates the Prompt Chaining pattern from Anthropic's  article

<Frame caption="Credits of the image to Anthropic">
  <img src="https://mintcdn.com/latitudellms/s61HT3nZZvygRuaw/assets/anthropic-building-agents/prompt-chaining.png?fit=max&auto=format&n=s61HT3nZZvygRuaw&q=85&s=52cffc1eb8e96256cd42958d9c1819d1" width="2401" height="1000" data-path="assets/anthropic-building-agents/prompt-chaining.png" />
</Frame>

## Overview

Prompt chaining decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one. You can add programmatic checks on any intermediate steps to ensure that the process is still on track.

This workflow trades off latency for higher accuracy by making each LLM call an easier, more focused task.

## When to use

Tasks that can be cleanly decomposed into fixed subtasks.

## Using prompt chaining in Latitude

```markdown Marketing Copy theme={null}
---
provider: openai
model: gpt-4.1
temperature: 0.7
---

<step as="marketing_copy">
  <system>
    You are a creative marketing copywriter. Create compelling marketing copy for the given product.
  </system>

  <user>
  Create marketing copy for: {{ product_description }}
  Target audience: {{ target_audience }}
  Tone: {{ tone }}
  Length: {{ length }}
  </user>
</step>

<step as="translation">
  <system>
    You are a professional translator with marketing expertise.
    Translate the provided marketing copy while maintaining its persuasive impact and cultural relevance.
  </system>

  <user>
  Translate the following marketing copy to {{ target_language }}:

  {{ marketing_copy }}

  Ensure the translation:
  1. Maintains the original tone and persuasive impact
  2. Adapts cultural references appropriately
  3. Uses marketing language natural to {{ target_language }} speakers
  </user>
</step>

<system>
  You are a quality assurance specialist. Review both the original and translated marketing copy to ensure quality and consistency.
</system>

<user>
  Review the marketing copy creation and translation process:

  Original copy:
  {{ marketing_copy }}

  Translated copy:
  {{ translation }}

  Provide:
  1. Quality assessment (1-10)
  2. Any improvements needed
  3. Final recommendation
</user>
```

This pattern is particularly effective when you have a clear process that can be broken down into logical stages, and when the quality benefits of step-by-step processing outweigh the increased latency and cost.
