AI Gateway Cost-Routed Two-Turn Conversation
A 2-step recipe with Vercel. We can help you get access.
Recipe · 2 steps
AI Gateway Cost-Routed Two-Turn Conversation
with Vercel
Two cost-routed chat completions chained into a single conversation.
- Send the first chat completion, sorting providers by cost via the gateway routing options.
- Continue the conversation by replaying the prior user and assistant turns and appending the follow-up message, again sorting by cost.
What you'll need to have ready
- apiKey: Vercel AI Gateway API key (AI_GATEWAY_API_KEY) used as a Bearer token.
- model: Model id in 'provider/model-name' form.
- prompt: The initial user message.
- followUp: The follow-up user message for the second turn.
For your developer
Arazzo workflow vercel:costRoutedConversation, 2 operations: createChatCompletion → createChatCompletion. Specs on APIs.io.