Chapter 10
Give Me Options — Multiple Variations
Several candidates, one call
Back in Chapter 2’s exercise, one of the suggested prompts was a bakery tagline. If you tried it, you got one tagline, read it, and either liked it or didn’t. No second opinion, no picking between a few directions. This chapter fixes that with one method: generate_texts().
One call, several answers
$taglines = wp_ai_client_prompt( 'Write a tagline for a photography blog.' )
->generate_texts( 4 );
The number you pass in is how many variations you want back. $taglines comes back as an array of strings, four different taglines from one call, not four separate generate_text() calls wrapped in a loop. That distinction matters: asking for four variations in one request is both cheaper and faster than firing off four independent calls, and because the model generates them together, it tends to actually spread them across different angles rather than returning four near-identical rewordings.
Seeing four real options
Create chapter-10-multiple-variations.php inside includes:
<?php
/**
* Chapter 10: Give Me Options, Multiple Variations
* Usage: add [ai_course_ch10] to any page or post to see the output.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access.
}
function ai_course_ch10_multiple_variations() {
$taglines = wp_ai_client_prompt( 'Write a one-sentence tagline for a bakery website.' )
->using_temperature( 0.9 )
->generate_texts( 4 );
if ( is_wp_error( $taglines ) ) {
return 'Could not generate taglines right now: ' . esc_html( $taglines->get_error_message() );
}
$output = '<ol>';
foreach ( $taglines as $tagline ) {
$output .= '<li>' . wp_kses_post( $tagline ) . '</li>';
}
$output .= '</ol>';
return $output;
}
add_shortcode( 'ai_course_ch10', 'ai_course_ch10_multiple_variations' );
Notice using_temperature( 0.9 ) is back from Chapter 6, chained on before generate_texts(). That’s deliberate: at a low temperature, four variations tend to come back nearly identical to each other, which defeats the point of asking for options. A higher temperature gives the four candidates room to actually differ.
Add [ai_course_ch10] to a page and load it. You get a numbered list of four distinct bakery taglines from a single call, not one answer you’re stuck with.
Warning, if you’re on OpenAI: two separate issues can show up here, and they look different, worth telling apart.
If you get back four taglines, but they’re nearly identical, that’s the temperature issue from Chapter 6: OpenAI’s reasoning models (the GPT-5 family, o1, o3) don’t support temperature, so using_temperature( 0.9 ) here has no effect.
If you get back only one tagline instead of four, this isn’t limited to reasoning models. Testing confirmed the same behavior directly against gpt-4o, a standard non-reasoning model.
The current AI Provider for OpenAI plugin appears to return only one result from generate_texts() regardless of which OpenAI model is used, most likely because it’s built on OpenAI’s Responses API, which doesn’t support requesting multiple completions in a single call at all, confirmed in OpenAI’s own documentation.
This isn’t a model-specific quirk the way the temperature issue is, it’s a limitation of the connector itself, at least as of when this chapter was written.
Either way, the workaround is the same: switch to a different connected provider for this chapter, or wait for Chapter 19’s using_model_preference(), though be aware that won’t help with this specific issue if every OpenAI model shares it.
Worth checking the AI Provider for OpenAI plugin’s changelog too, this is exactly the kind of gap that gets fixed in a future update.
Where this pattern actually earns its keep
A single generated result is fine when you trust the model to get it right the first time, a quick internal summary, a one-off haiku, nobody’s reviewing it. It’s the wrong fit anywhere a person is going to make a judgment call: picking a tagline for a real business, choosing a subject line, selecting an image caption. Handing someone four real options and letting them pick produces a better outcome than any single generation, because “which of these do I like” is a much easier decision than “is this one good enough.”
Try it yourself
Take the bakery tagline example above, or swap in a real prompt from your own project, and generate four variations of it. Read all four and actually pick a favorite, out loud if you have to, the way a real user of your feature would. If none of the four feel usable, that’s useful information too, it usually means the prompt itself needs to be more specific about tone or audience, not that you need more variations.