Ship AI with Laravel: Give Your AI Agent Live Web Search

Published on by

▶️ Watch the video tutorial (8 minutes)

Our agent can look up orders, search the knowledge base, and hold real conversations. But ask it "is FedEx having delays right now?" and it has nothing useful to say. Our knowledge base covers our policies, not things that change by the minute. Shipping carrier delays, current product availability, outage pages. The agent either guesses or admits it doesn't know.

In this episode we fix that by giving the agent access to the live web. The SDK ships with two provider tools: WebSearch to find information online and WebFetch to read a specific page. The provider handles the actual searching, so we just configure which domains to allow and how many results to return.

I add WebSearch to the support agent, cap it at five results, and lock the allow list down to shipping carriers. That allow list is the part you don't skip. Without it the agent could browse anywhere on the internet and hand whatever it finds back to a customer. I also update the instructions so the agent stays transparent about where its answer came from, our official policy versus something it pulled off the web.

Then I test it. I ask about an order that shipped via FedEx with no tracking update, and the agent checks both the order and FedEx's status. I ask how long USPS Priority Mail takes, and it returns the current answer instead of guessing from training data that might be months old. I also show how to bias results by location if your customers are in a specific region.

One note: WebFetch is currently supported on Anthropic and Gemini. Since this series runs on OpenAI, we stick with WebSearch, which handles the use case fine.

That gives the agent five tools: order lookup, customer history, knowledge base search, document search, and now live web search. It can answer from our database, our documentation, and the live web.

Next episode we add the production infrastructure. Queued responses, provider failover, and middleware for logging and rate limiting. The stuff that keeps this running at 2am when you're asleep.

⭐ GitHub: https://github.com/harris21/ship-ai-with-laravel

▶️ Watch Episode 8 now →

Harris Raftopoulos photo

Senior Software Engineer • Staff & Educator @ Laravel News • Co-organizer @ Laravel Greece Meetup

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

The latest

View all →
Lattice: Describe Inertia UIs in PHP image

Lattice: Describe Inertia UIs in PHP

Read article
How We Cached Laravel News at the Edge with Fast Laravel image

How We Cached Laravel News at the Edge with Fast Laravel

Read article
The artisan dev Command in Laravel 13.16.0 image

The artisan dev Command in Laravel 13.16.0

Read article
LaraOwl: Self-Hosted Monitoring for Laravel Applications image

LaraOwl: Self-Hosted Monitoring for Laravel Applications

Read article
Filament Storage Monitor: Track Disk Usage From Your Filament Dashboard image

Filament Storage Monitor: Track Disk Usage From Your Filament Dashboard

Read article
Subscriptionify: Feature-Based Subscription Management for Laravel image

Subscriptionify: Feature-Based Subscription Management for Laravel

Read article