Search by

saucebase / ai-chat

saucebase

Laravel AI chat for your SaaS: streaming replies, conversation history, web search, image generation, tools that read the user's account, monthly limits per plan and a model picker for OpenAI, Anthropic, Gemini and more. Built on laravel/ai, on Vue and React (Inertia).

Package info

github.com/saucebase-dev/ai-chat

Homepage

Language:TypeScript

Type:saucebase-module

pkg:composer/saucebase/ai-chat

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.1 2026-12-01 20:36 UTC

This package is auto-updated.

Last update: 2026-12-01 20:58:26 UTC


README

Tests Release Saucebase Core License

Laravel AI chat for Saucebase: streaming replies, conversation history, web search, image generation and plan limits, built on laravel/ai, on Vue or React. It opens at /chat.

A module for Saucebase, the AI-ready Laravel SaaS kit. Modules are Composer packages you add to a Saucebase app; once installed, the code is yours to change.

Features

  • Streaming replies in markdown, with the steps that led to them: thinking, tool calls and sources
  • Conversations per user: titled automatically, renamed, pinned, deleted and searched, grouped by date; long chats load older messages as you scroll up
  • Tools: web search (the provider's own), image generation, and about_my_account, which reads the signed-in user's profile, plan and workspace from the installed modules
  • Model picker with the models you offer
  • Monthly limits per plan for messages and images, with the Billing module: a usage bar near the limit and an upgrade link
  • Dictation in the message box
  • Admin panel: provider API keys, the models users can pick, extra instructions, image settings, and a read-only conversation viewer
  • Test mode: a demo provider answers, so you can build and try the chat without a key or tokens
  • WebMCP (beta, off until turned on): the visitor's own browser agent can ask the assistant and read or switch chats
  • Two layouts: a "Chat" item in the app sidebar and the chats in a panel of their own, or the chats in the app sidebar for a chat-first app
  • Vue and React

Install

New to Saucebase? Start a new app and pick ai-chat when it asks for modules:

curl -fsSL https://install.saucebase.dev | bash

It installs PHP and Composer if they're missing. With the CLI already installed, run saucebase new my-app instead.

With your Saucebase app ready, add AI Chat:

php artisan saucebase:module-install ai-chat
npm install && npm run build

It needs Auth for sign-in. Conversation titles are written by a queued job, so run a queue worker.

Configuration

In the admin panel, under Settings → AI chat (people with the manage ai chat permission, and admins), in four sections:

  • Models: each provider with its API key (stored encrypted; a key set in .env, laravel/ai's config/ai.php, works too) and the models users can pick, and the default model. Only providers with a key are offered. In test mode the page says the demos replace them.
  • Assistant: instructions added to the assistant's own.
  • Images: the provider, model and quality generate_image uses. .env can set them too (AI_CHAT_IMAGE_PROVIDER, AI_CHAT_IMAGE_MODEL, AI_CHAT_IMAGE_QUALITY); without either, laravel/ai's default for images.
  • WebMCP (beta): off by default. On, the chat offers its tools to the visitor's own browser agent, in browsers that support WebMCP (a draft standard).

The conversation viewer is under Chats.

Where the chat list lives is sessions in config/ai-chat.php (publish the config, or set it from your own service provider):

Value Layout
page (default) A "Chat" item in the app sidebar. On the chat, the app sidebar starts collapsed to its icons, and the chats, search and WebMCP sit in a resizable panel of their own (a sheet on phones).
sidebar The chats and WebMCP in the app sidebar on every page, with no item and no panel. For an app where the chat is the product.

Limits

With Billing installed, a plan can set two limits per month, as capabilities on its product:

  • ai_chat_messages: messages a user can send
  • ai_chat_images: images the assistant can generate for them

A limit a user's plans don't set is unlimited. At the limit, sending is turned off until the next month, with a link to upgrade.

Test mode

AI_CHAT_TEST_MODE=true

Every provider call goes to a demo provider: the picker offers the demos (Demo: Steps, Demo: Image…), and titles and images use it too. The real agent, tools, storage and streaming all run. Each demo is a JSON file in resources/demos/; adding one is adding a file. Test mode is refused in production.

Add a tool

  1. A class in src/Ai/Tools/ implementing Laravel\Ai\Contracts\Tool, with a NAME constant. Take the user in the constructor and return a string (JSON for structured results). AboutMyAccount is the example to copy.
  2. Return it from ChatAgent::tools().
  3. Give it labels in TOOL_LABELS (resources/js/lib/tools.ts), or the steps show its name.
  4. Optionally, a demo in resources/demos/ so test mode can show it.

Tests

php artisan test --compact modules/ai-chat/tests
npx vitest run modules/ai-chat
npx playwright test modules/ai-chat/tests/e2e --project="@ai-chat*"

License

MIT. See LICENSE.