Laravel AI Agent Live Web Search with WebSearch Tool | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Give Your Laravel AI Agent Live Web Search with WebSearch Tool        On this page       1. [  Why Your AI Agent Needs Live Web Access ](#why-your-ai-agent-needs-live-web-access)
2. [  The Two Provider Tools: WebSearch and WebFetch ](#the-two-provider-tools-websearch-and-webfetch)
3. [  Adding WebSearch to the Support Agent ](#adding-websearch-to-the-support-agent)
4. [  Testing Real-World Queries ](#testing-real-world-queries)
5. [  The Agent's Full Tool Set (After Episode 8) ](#the-agents-full-tool-set-after-episode-8)
6. [  Key Takeaways ](#key-takeaways)

  ![Give Your Laravel AI Agent Live Web Search with WebSearch Tool](https://cdn.msaied.com/236/6b6b7526226d6643c3704b5bcce25801.png)

 [  Laravel ](https://msaied.com/articles?category=laravel) [  AI ](https://msaied.com/articles?category=ai)  #Laravel   #AI Agent   #WebSearch   #PHP   #OpenAI   #Support Bot  

 Give Your Laravel AI Agent Live Web Search with WebSearch Tool 
================================================================

     18 Jun 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Why Your AI Agent Needs Live Web Access  ](#why-your-ai-agent-needs-live-web-access)
2. [  02   The Two Provider Tools: WebSearch and WebFetch  ](#the-two-provider-tools-websearch-and-webfetch)
3. [  03   Adding WebSearch to the Support Agent  ](#adding-websearch-to-the-support-agent)
4. [  04   Testing Real-World Queries  ](#testing-real-world-queries)
5. [  05   The Agent's Full Tool Set (After Episode 8)  ](#the-agents-full-tool-set-after-episode-8)
6. [  06   Key Takeaways  ](#key-takeaways)

 Why Your AI Agent Needs Live Web Access
---------------------------------------

A well-built Laravel AI support agent can query order history, search a knowledge base, and hold multi-turn conversations. But the moment a customer asks "Is FedEx experiencing delays right now?", a static knowledge base falls flat. Shipping carrier statuses, outage pages, and real-time availability change by the minute — and training data can be months stale.

Episode 8 of the *Ship AI with Laravel* series solves this by wiring the agent into the live web using the SDK's built-in provider tools.

The Two Provider Tools: WebSearch and WebFetch
----------------------------------------------

The Laravel AI SDK ships with two provider-level tools:

- **WebSearch** — queries the web and returns a ranked list of results.
- **WebFetch** — fetches and reads a specific URL's content.

> **Note:** WebFetch is currently supported on Anthropic and Gemini only. Because this series runs on OpenAI, WebSearch is the right choice and handles the use case well.

Adding WebSearch to the Support Agent
-------------------------------------

The integration involves three decisions:

1. **Cap the result count.** The example limits results to five to keep context concise and costs predictable.
2. **Define an allow list.** Restrict the domains the agent may search. Without this, the agent could browse anywhere on the internet and return unvetted content to customers.
3. **Update the system instructions.** Tell the agent to be transparent about the source of its answer — distinguishing between your official policy and something retrieved from the live web.

A simplified configuration looks like this:

```php
WebSearch::make()
    ->maxResults(5)
    ->allowedDomains([
        'fedex.com',
        'ups.com',
        'usps.com',
    ])

```

The provider handles the actual HTTP requests and ranking; your code only declares the constraints.

Testing Real-World Queries
--------------------------

With WebSearch active, the agent handles two scenarios that previously produced unhelpful responses:

- **FedEx delay check** — the agent queries both the order record and FedEx's live status page, then synthesises a single answer.
- **USPS Priority Mail transit time** — instead of guessing from potentially outdated training data, the agent returns the current published estimate.

You can also bias results by geographic region if your customer base is concentrated in a specific area, giving locally relevant answers without extra application logic.

The Agent's Full Tool Set (After Episode 8)
-------------------------------------------

At this point the support agent has five tools available:

- Order lookup
- Customer history
- Knowledge base search
- Document search
- Live web search

It can now answer from your database, your internal documentation, *and* the live web — covering the full spectrum from structured business data to real-time external information.

Key Takeaways
-------------

- Use the SDK's `WebSearch` provider tool to give a Laravel AI agent access to live web results.
- Always define an `allowedDomains` list — leaving it open lets the agent retrieve and surface arbitrary web content.
- Cap `maxResults` to control context size and inference cost.
- Update system instructions so the agent cites whether an answer comes from internal policy or a live web source.
- `WebFetch` (for reading a specific URL) is currently limited to Anthropic and Gemini; OpenAI users should rely on `WebSearch`.
- Location biasing is available when your users are concentrated in a specific region.

---

*Source: [Ship AI with Laravel: Give Your AI Agent Live Web Search](https://laravel-news.com/ship-ai-with-laravel-give-your-ai-agent-live-web-search) — Laravel News, June 18, 2026*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fgive-your-laravel-ai-agent-live-web-search-with-websearch-tool&text=Give+Your+Laravel+AI+Agent+Live+Web+Search+with+WebSearch+Tool) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fgive-your-laravel-ai-agent-live-web-search-with-websearch-tool) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Why is the domain allow list required when using WebSearch in a Laravel AI agent?        Without an allow list, the agent can browse any website and return unvetted content directly to customers. Restricting allowed domains ensures the agent only retrieves information from trusted sources, such as official carrier status pages. 

      Q02  Can I use WebFetch instead of WebSearch with OpenAI in Laravel?        No. WebFetch is currently supported only on Anthropic and Gemini providers. If your Laravel AI project runs on OpenAI, you should use WebSearch, which covers the same real-time lookup use case. 

      Q03  How do I limit the number of web results returned by the WebSearch tool?        Pass a maxResults value when configuring the tool — for example, setting it to 5. This keeps the context window concise and helps control inference costs. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![PostgreSQL CTEs, Recursive Queries, and Lateral Joins in Laravel](https://cdn.msaied.com/241/32858f9c67eae0649999c32a6d31818f.png) laravel postgresql query-builder 

### PostgreSQL CTEs, Recursive Queries, and Lateral Joins in Laravel

Go beyond basic Eloquent with raw PostgreSQL power: composable CTEs, recursive tree traversal, and LATERAL joi...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 19 Jun 2026     3 min read  

  Read    

 ](https://msaied.com/articles/postgresql-ctes-recursive-queries-and-lateral-joins-in-laravel) [ ![PostgreSQL Window Functions in Laravel: Ranking, Running Totals, and Gap Detection](https://cdn.msaied.com/239/f588e7cbf8e6d3317a581ce0fa27140d.png) laravel postgresql eloquent 

### PostgreSQL Window Functions in Laravel: Ranking, Running Totals, and Gap Detection

Window functions let you compute rankings, running totals, and gaps directly in SQL without pulling rows into...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 19 Jun 2026     3 min read  

  Read    

 ](https://msaied.com/articles/postgresql-window-functions-in-laravel-ranking-running-totals-and-gap-detection) [ ![Custom Eloquent Casts: Encapsulating Domain Logic Inside Model Attributes](https://cdn.msaied.com/238/8e843e57a34f81f853eedefae629c09b.png) laravel eloquent domain-driven-design 

### Custom Eloquent Casts: Encapsulating Domain Logic Inside Model Attributes

Custom Eloquent casts let you push value-object logic directly into model attributes, keeping controllers and...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 19 Jun 2026     3 min read  

  Read    

 ](https://msaied.com/articles/custom-eloquent-casts-encapsulating-domain-logic-inside-model-attributes) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
