Generate and translate copy
Create an AI agent workflow that generates and translates copy
Overview
Prompt chaining is an AI workflow pattern that decomposes a complex task into a sequence of steps, where each LLM call processes the output of the previous one. This approach trades off latency for higher accuracy by making each LLM call an easier, more focused task, with the ability to add programmatic checks between steps to ensure the process remains on track.
Example task
In this example, we’ll create a workflow that generates and translates copy. This approach is particularly effective when tasks require different models or approaches for different inputs.
This task:
- Uses
generateText
from Vercel’s AI SDK to interact with OpenAI models - Uses
experimental_telemetry
to provide LLM logs - Generates marketing copy based on subject and target word count
- Validates the generated copy meets word count requirements (±10 words)
- Translates the validated copy to the target language while preserving tone
Run a test
On the Test page in the dashboard, select the generate-and-translate-copy
task and include a payload like the following:
This example payload generates copy and then translates it using sequential LLM calls. The translation only begins after the generated copy has been validated against the word count requirements.