15  Transactional Interactions via API

We’ve now practiced using an API for conversational interactions with generative AI models, much like using an online chatbot interface. You submit a prompt, the model responds, you respond again, and the model’s next response takes the entire conversation into account. This method is valuable for brainstorming and other processes that benefit from iteration: you can adjust your request after viewing the model’s response or push the conversation in a new direction. And while you can save the model’s responses with the chat$get_turns() function, it may not always be easy to locate the precise output you want, especially after a long conversation.

This brings us to the second method of interacting with a generative AI model that we briefly discussed before: transactional interactions. I use this term because it captures the one-off nature of the interaction well. You ask the model to do something, the model does it, and then you continue on with your workflow. This mirrors ordinary transactions: you go to the grocery store, pick out your items, buy them, and continue on with your day. There is no need for an extended interaction.

Transactional interactions are often more useful when you are completing tasks at scale. It does not make sense to maintain a conversation when you are asking the model to apply a rubric to an assessment, generate items with certain characteristics, or complete other time-intensive tasks that need to be repeated many times.

This does not mean that conversational interactions are not valuable when incorporating generative AI models into your workflow. When building prompts for a workflow, I find conversational interactions extremely valuable for helping optimize the prompt. I often ask the model to help me identify missing information or suggest how to provide an example output structure that will improve future downstream tasks I have planned. This kind of prompt-about-a-prompt is often called metaprompting. It may start as a conversation, but once the prompt is ready for repeated use, it should become a stable, testable instruction that can be used transactionally in your workflow.

Even then, it is often useful to move back and forth between the two approaches:

For these reasons (and more), it is useful to learn a little about prompt engineering and prompting strategies. These skills may be less important in conversational interactions because you can give the model immediate feedback, but they are essential when crafting prompts for workflows that will run at scale.