Credits of the image to Anthropic
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
---
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.