Laravel AI SDK: "Sensitive" Data in Prompts and AI Dashboard Package
Chapters7
The presenter explains that 2026 will bring more AI powered SaaS projects and demos how to build features with AI using Laravel AI SDK.
A practical look at safely supplying data to AI models in Laravel apps, plus a hands-on demo of the Laravel AI SDK and the Laravel AI Orbit dashboard.
Summary
Laravel Daily’s latest deep dive by author shows how to responsibly send data to external AI models like OpenAI or Claude Code when building AI-powered features in Laravel. The video walks through building a safe, filtered company context and documents context before triggering an LLM, emphasizing authorization, rate limiting, and explicit data scoping to avoid leaking sensitive information. The core demonstration centers on a multi-tenant Laravel app where a “What should I do next?” button prompts the AI to generate prioritized recommendations. The host then introduces the Laravel AI Orbit dashboard as a standalone observability tool to monitor AI runs, token usage, model choices, prompts, pricing, and audit logs (including PII detection). Throughout, practical tips are sprinkled about prompt design, system instructions, and the benefits of structured response schemas. The session also plugs a Laravel Daily course on the Laravel AI SDK and teases hands-on features like a prompt library and sandbox playground within Orbit. The takeaway is clear: treat data minimization and transparent accountability as first-class concerns when integrating AI into production Laravel apps.
Key Takeaways
- Build a safe context by filtering and shaping company data before sending to the LLM, returning only the fields you explicitly allow.
- Use a dedicated action class with an invoke method to encapsulate the LLM call, including a system prompt that constrains the model and a strict response schema.
- Implement authorization and rate limiting in the flow to prevent abuse and token bloat, especially in multi-tenant setups.
- Laravel AI Orbit provides end-to-end observability: token counts, per-agent breakdown, model and payload inspection, pricing rules, and an audit log for PII detection.
- The toolkit demonstrates practical patterns for production-ready AI integration, including prompt safety, structured outputs, and real-time monitoring.
Who Is This For?
Laravel developers integrating AI features who want proven patterns for data safety, prompt design, and monitoring, plus a hands-on look at the Laravel AI SDK and Orbit dashboard.
Notable Quotes
"So, this is basically the place where you would maybe limit, for example, company name to not be sent to LLM or other fields that are more sensitive, depending on your scenario."
—Shows the data-filtering step to minimize sensitive data leakage.
"We build safe context and return the array from that service to the action, right?"
—Highlights the separation of concerns for data preparation before the LLM call.
"The system prompt for the AI is: You are assistant. Your job is this and that. Do not ask for any sensitive data that may be possible."
—Illustrates how a strong system prompt guides model behavior and data handling.
"In the Laravel AI Orbit dashboard you can check the model, payload, usage and events for a specific run."
—Demonstrates observability features of Orbit.
"This quick demo is basically to show building safe context, and the prompt is designed to return a structured array."
—Encapsulates the core pattern of the workflow.
Questions This Video Answers
- how to safely send data to OpenAI from Laravel without exposing sensitive business information
- what is Laravel AI Orbit and how does it help monitor AI prompts
- how to implement a structured response schema for LLM outputs in Laravel
- how to enforce authorization and rate limiting for AI prompts in multi-tenant Laravel apps
- what are best practices for prompt design to avoid leaking sensitive data in AI integrations
Laravel AI SDKLaravel AI OrbitOpenAImulti-tenant Laravelprompt safetysystem promptsstructured data schemasLLM integrationPII detectiontoken usage monitoring
Full Transcript
Hello guys. In 2026, you will see more and more client requests and projects with something AI-powered. AI-powered SaaS, some project with AI inside. So, the question will be not do you use AI as a developer to write code like Claude Code or Codex or Cursor, but the question will be can you build functions and features and projects with AI inside? And for that, in this video, I will show you two things. I will show you a Laravel AI SDK package trying to answer the question. So, this is business document kind of organizing and analyzing project with one main feature, what should I do next?
Is kind of a magic button for a business based on a lot of data in that project. And I tried to recreate such scenario, and I will show you kind of the safer way because the question is how do you give the data to AI, which is OpenAI or Claude Code Anthropic, so some external model, which needs to make decision and make recommendation based on pretty sensitive business data. So, I will show you my way of kind of making the prompt a bit safer and obfuscating and hiding some sensitive data. So, that will be number one topic of this video, and number two will be a package, new package Laravel AI Orbit, which is kind of a dashboard for Laravel AI SDK usage like this.
So, I will show you that in action. So, let's dive in. First, the demonstration. What does that button do? So, in our database, there are a lot of things about certain company. So, there's company {slash} one. It's a multi-tenancy system based on Laravel starter kit. So, we have company, in this case, pre-formation, and based on the status of that company, so as you see, there's no document for company ID one, which means that the answer to this button, what should I do next, is probably to start from the beginning filling a lot of documents. So, this is actually the goal behind this project.
Of course, I recreated only small part of it, but the logic is to analyze the status kind of the checklist for company formation with a lot of details inside. So, this is what that button actually does. It sends a prompt to LLM. In this case, it's OpenAI with Laravel AI SDK and comes up with list of recommendations. You will see like in 5 seconds or so, hopefully. The recommendation page. Yep, here it is. So, this was in live mode. This is how much it took in terms of time and next action with high urgency or not high urgency.
Of course, warning disclaimer that it's not a financial official advice, but basically summary comes from LLM. So, now let me show you the code. And by the way, if you haven't worked with Laravel AI SDK at all, I have a course on Laravel Daily. As soon as it was released in February 2026, I released a video course. 1 hour long with really practical examples. First, fun examples with image and text and audio and then a bit deeper or much deeper with chatbot and documents for business use cases. So, I will put the link to that course in the description below.
So, this is a Laravel application with Livewire Starter Kit and in companies show, one of the page element is this recommend button. And this is a Livewire component. Then, if we open that component, this is a class-based component. I prefer that for longer components instead of all-in-one single class component promoted by Livewire 4. Sometimes, it works, but not in this case. It has quite a lot of logic. So, then the button generate, the function generate, which is called by that button, makes the authorization for that specific company. This is important for multi-tenancy system. Then, we have generate recommendation, which is actually an action.
Probably, better way would be to have action as a suffix, but in this case, I don't have that. So, important for such system is authorization, then rate limiting for preventing the LLM abuse and token usage skyrocketing. And then, if everything is fine, then we call the action. And then that action class has invoke method, kind of the main method to actually call the LLM. But before calling LLM, this is probably the main thing that I want to show you, build safe context. And then only that safe context is passed to AI agent class, which is Laravel AI SDK.
So, what's inside of that build safe context? We have company as an object. So, from the database, we have company data. Then inside, we build the relationships that we need. And then inside of that service, which is exactly the service for company context, build company context. So, only the fields that we want to be sent. And this is the place where you would maybe limit, for example, company name to not be sent to LLM or other fields that are more sensitive, depending on your scenario. So, this is building company context. This is building documents context.
And then other relationships to the company have their own private functions with some collection operations. And those details are not that important. What is important is that we build safe context and return the array from that service to the action, right? So, this is our result, context. And then we build the prompt, which is another private method in the same action in this case. And this is the actual prompt. Analyze the following company context and return structured recommendations. And then with that prompt and that context JSON encoded, we call AI agent from Laravel AI SDK.
And this is the class that works directly with LLM. And this is where we have instructions. So, this is kind of the system prompt for LLM. You are assistant. Your job is this and that. Important rules. Do not ask for any sensitive data that may be possible. Of course, it depends on your situation. But yeah, these are kind of system instructions on top of or in front of those specific prompts that come from action. And then also we limit the data to be returned only to these. So, this is what we expect to be returned.
Summary, priority, next actions, and so on. Which then is used for that page, for the result page. So, we have structured array, validate structure, and then we save the recommendation in the local database. So, this is eloquent model. And that method validate structure response is validator make. By the way, not sure if you know, you can use Laravel validator like this outside of any form request or controller or something like that. You can just validate array with those rules. And then if it fails, you throw validation exception. So, then that validation exception is caught. Or actually not even here.
This is action. And then in the Livewire component here. Yep, we have try catch here. So, this is what would be caught with whatever you want to report, save, or redirect back. So, this quick demo is basically to show this thing built safe context. If you work with sensitive data, you need to have some kind of filter, a funnel, whatever you call it, some kind of layer to return or to use only the data that is safe. And also in the prompt, as well in the agent of Laravel AI SDK, also add a lot of instructions so that the agent would not try to ask for sensitive information and also would return the expected structure like this with schema.
This is a great, by the way, structure and functionality by Laravel AI SDK package. So, this is not only the wrapper of OpenAI, Anthropic, and other models, but also it provides the schematic structured way how to deal with returned data, which sometimes is unpredictable. And then also, I promised to show you new package, Laravel AI Orbit, standalone observability dashboard develop So, yeah, I don't like the official descriptions. I like screenshots. So, this is what you need to see. And I have installed it, and let me show you that in action. So, this is my /ai-orbit dashboard with three runs of AI queries, only two of them successful, from what I remember.
And this is what we can monitor. Input tokens, output tokens, then tokens by specific agent, if you have multiple AI SDK agents in your Laravel project. And then what do we have here? Conversations, nothing runs. So, these are runs with tokens. Cost is unpriced, because probably we need to provide the pricing formula, so add pricing rule. Yeah, so you can manually enter the pricing, and then it would calculate the prices as well, but even without price, what we can do here, we can click on AI Orbit specific run, and check the model, check the payload, check the usage and events.
I only don't see the result returned. Maybe it was not logged, I'm not sure. And then also, how much it took, so we have almost 12 seconds. This is pretty normal for this kind of model. And by the way, how much it actually cost with OpenAI API. So, I had 4 cents used during my testing before this video, and now I have refreshed that, and I have 5 cents total spent, so that one query, one prompt was roughly 1 cent. Also, in that package, there are a lot of menu items like playground, for example, so you can test it out, open sandbox.
You can check the usage, again without the pricing in this case, but also what do we have here? Prompt lab. So, this is, as I understand, also kind of playground to compare models with the same prompt, then pricing, you saw that already, alerts for budgeting, health, this is another kind of summary dashboard, audit, what do we have here? Audit log for detection of potentially identifiable information. So, this is interesting. You can put in the prompt, and then it would scan for personally identifiable information. Let's test it actually. So, this would be the prompt, can you check if my email is in some kind of hacker DB?
And let's see. Yep, email detected. So, yep, it works. And then you have prompts, which is prompt library. Reusable prompts for the same project. I don't think I would use it within the one project context. I'm thinking to build my own prompt libraries on GitHub, probably for usability for multiple projects, but yeah, maybe some of you have the need to have prompts within the same project for just playing around. So, yeah, this dashboard, I really liked it, pretty powerful, and of course, you can secure that with like middlewares or logins or other things in the code, and there are a lot of things to get familiar with here.
Some things configurable, so yeah, you can read the full docs for more details. So, yeah, if you go back to the original Upwork job, AI-powered SaaS, I guess you will get more requests from clients for similar projects, like AI SDK or any other AI provider. You can use other packages, not necessarily even Laravel, but you would need to call AI for doing something, and then process the result. What do you think about my way of doing this or do you have any other ways or special tricks or additional packages to cover such use cases? Let's discuss in the comments below as usual.
That's it for this time and see you guys in other videos.
More from Laravel Daily
Get daily recaps from
Laravel Daily
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.









