Title: web search?
Last modified: October 5, 2026

---

# web search?

 *  Resolved [Geleosan](https://wordpress.org/support/users/geleosan/)
 * (@geleosan)
 * [3 days, 5 hours ago](https://wordpress.org/support/topic/web-search-2/)
 * Hi. Can `simpleTextQuery()` or `mwai_ai_query` enable the web search tool for
   a request, and with which `$params` or query property?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [3 days, 5 hours ago](https://wordpress.org/support/topic/web-search-2/#post-19037188)
 * Hi [@geleosan](https://wordpress.org/support/users/geleosan/),
 * Yes, both can! 😊 Web search is a built-in tool, and you enable it by adding 
   web_search to the tools of the query.
 * With simpleTextQuery, pass it in the params:
 *     ```wp-block-code
       $mwai->simpleTextQuery( $message, [ 'tools' => [ 'web_search' ] ] );
       ```
   
 * With the mwai_ai_query filter, set it on the query itself, merged with the existing
   tools so you keep whatever the chatbot already enabled:
 *     ```wp-block-code
       $query->set_tools( array_merge( $query->tools, [ 'web_search' ] ) );
       ```
   
 * It works with OpenAI (native OpenAI environment, through the Responses API), 
   Anthropic, Google and OpenRouter. On an OpenAI-compatible custom environment 
   it is dropped, and AI Engine writes a line in the PHP error log explaining why.
 * Have a nice day!
 *  Thread Starter [Geleosan](https://wordpress.org/support/users/geleosan/)
 * (@geleosan)
 * [3 days, 2 hours ago](https://wordpress.org/support/topic/web-search-2/#post-19037259)
 * Cool! Thank you.
 * Can the web_search tool in simpleTextQuery take options like max_uses and allowed_domains(
   as in Anthropic’s web search tool definition)? Searches are costing me about 
   $1 per run and I’d like to cap them.
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [2 days, 16 hours ago](https://wordpress.org/support/topic/web-search-2/#post-19037604)
 * Hi again [@geleosan](https://wordpress.org/support/users/geleosan/),
 * Not through _simpleTextQuery_ itself, but I just added a filter for exactly this!
   😊 It is called _mwai\_anthropic\_body_, it lets you change the request right
   before it goes to Anthropic, and it will be in the next release (this Thursday).
   With it, you can tune the web search tool like this:
 *     ```wp-block-code
       add_filter( 'mwai_anthropic_body', function( $body, $query ) {
         foreach ( $body['tools'] ?? [] as $i => $tool ) {
           if ( ( $tool['name'] ?? '' ) === 'web_search' ) {
             $body['tools'][$i]['max_uses'] = 2;
             $body['tools'][$i]['allowed_domains'] = [ 'example.com' ];
           }
         }
         return $body;
       }, 10, 2 );
       ```
   
 * AI Engine already caps it at 5 searches by default. The searches themselves are
   cheap (about one cent each); what makes a run cost $1 is that every page found
   is read by the model as input tokens. So _max\_uses_ is the right lever, and 
   a smaller model like Haiku will divide the bill too.
 * Have a nice day!
   Jordy.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fweb-search-2%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/ai-engine/assets/icon-256x256.png?rev=3630444)
 * [AI Engine - The Chatbot, AI Framework & MCP for WordPress](https://wordpress.org/plugins/ai-engine/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ai-engine/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ai-engine/)
 * [Active Topics](https://wordpress.org/support/plugin/ai-engine/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ai-engine/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ai-engine/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [2 days, 16 hours ago](https://wordpress.org/support/topic/web-search-2/#post-19037604)
 * Status: resolved