Download the PHP package halilcosdu/laravel-chatbot without Composer

On this page you can find all versions of the php package halilcosdu/laravel-chatbot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-chatbot

Laravel Chatbot

Latest Version on Packagist Total Downloads

A Laravel-native, stateful chatbot built on OpenAI's Responses and Conversations APIs. It manages the remote conversation, keeps a local Eloquent transcript, scopes threads to your users, and supports both synchronous and streamed responses through one facade.

Version 2.x does not use the deprecated Assistants API. If you are upgrading from 1.x, read the upgrade guide and migrate before the Assistants API shuts down on August 26, 2026.

What you get

Compatibility

Laravel Supported PHP versions Testbench
11.x (11.29+, legacy) 8.2, 8.3, 8.4 9.x
12.x (12.12+) 8.2, 8.3, 8.4, 8.5 10.x
13.x 8.3, 8.4, 8.5 11.x

The CI matrix tests every compatible combination above with both lowest and stable dependency sets. Laravel 11 reached upstream security end-of-life on March 12, 2026. Version 2.1 retains Laravel 11 runtime compatibility for migrations, but production applications should upgrade to Laravel 12 or 13. The Laravel 11 CI jobs use Composer's --no-blocking option solely to resolve that end-of-life framework; the package does not weaken a consuming application's Composer security policy.

Laravel 11 is not listed with PHP 8.5 because Laravel's support policy ends its PHP range at 8.4; use Laravel 12 or 13 when deploying on PHP 8.5.

Additional requirements:

Installation

Install the package with Composer:

Publish its configuration and migrations, then migrate:

Laravel discovers the service provider and ChatBot facade automatically.

Environment

At minimum, configure your API key:

Optional values:

OPENAI_PROMPT_ID remains available for applications already using reusable prompt objects. OpenAI's deprecation schedule says reusable prompts will shut down on November 30, 2026, so new integrations should keep instructions in application configuration instead.

Configuration

The published config/chatbot.php contains:

Put options shared by every managed response in response_options:

The package always supplies input and conversation, and it chooses streaming internally. Those keys cannot be replaced through managed thread methods.

The chatbot client is container-isolated from openai-php/laravel's application-level ClientContract. Your application's own OpenAI binding and config/openai.php can therefore coexist without replacing the credentials or timeout used by this package.

Quick start

The package creates one remote Conversation and stores the user and assistant messages locally. Later calls reuse the remote conversation ID so OpenAI retains the conversation state.

Managed API

Method Result Purpose
createThread($subject, $ownerId, $options) Eloquent thread Create a conversation and wait for the first answer.
createThreadStreamed($subject, $ownerId, $options) StreamedThreadResponse Create a conversation and iterate its first answer as text deltas.
updateThread($message, $id, $ownerId, $options) Eloquent message Continue a conversation and wait for the answer.
updateThreadStreamed($message, $id, $ownerId, $options) StreamedThreadResponse Continue a conversation and iterate text deltas.
listThreads($ownerId, $search, $appends) paginator List newest threads, optionally scoped and searched.
thread($id, $ownerId) Eloquent thread Retrieve a thread with its messages.
deleteThread($id, $ownerId) void Delete the remote Conversation and local thread.

Per-request options

The final $options argument is merged over response_options. It is useful for changing a model, token budget, reasoning effort, metadata, or supported tools for one request:

Passing a model explicitly bypasses a configured prompt_id. Passing a prompt uses that prompt and omits model and instructions, matching the package's existing prompt behavior.

Streaming responses

Streaming uses the Responses API's semantic events internally and exposes only text deltas. The returned object also gives you the local thread immediately:

StreamedThreadResponse is intentionally single-use. A successful terminal response.completed event is required before the package stores the assistant message. If the stream fails, ends early, or the consumer disconnects, the user message remains in the local transcript but no incomplete assistant message is invented.

Laravel streamed HTTP response

Reverse proxies may buffer output even when PHP flushes it. Disable buffering for this endpoint in your web server or proxy configuration. Streaming partial output also makes moderation harder than moderating a completed answer; account for that in production applications.

Listing and owner isolation

Pass the authenticated owner's ID to every read, update, stream, and delete call. The package applies the owner condition in the database query, including valid IDs such as 0; a mismatched owner receives Laravel's normal ModelNotFoundException.

Local data and custom models

threads stores the owner, short subject, and remote Conversation ID. thread_messages stores the ordered local transcript and is deleted with its parent thread.

To add casts, relationships, or tenant behavior, extend the package models:

Then configure the class:

Custom classes must be Eloquent models. Extending the package models is recommended so their relationship methods and bundled factories remain available. The package always uses the stable thread_id foreign key, even when your custom class has a different name.

Raw OpenAI access

Raw methods return the SDK's typed response objects and do not write local models:

Use the managed methods when you want conversation continuity and local persistence. Use the raw methods when you need API features that the managed text workflow does not interpret.

Migrating from 1.x

Version 1.x used Assistants threads (thread_*); version 2.x uses Conversations (conv_*). These IDs are not interchangeable.

After publishing and running the 2.x migrations, inspect and migrate your local transcripts:

Useful options:

The command:

See UPGRADE.md for the complete 1.x to 2.x migration guide.

Error handling

Managed responses throw HalilCosdu\ChatBot\Exceptions\ChatBotException when OpenAI returns a failed or incomplete response, produces no text, or ends a stream without a completion event.

Transport and authentication errors from the underlying SDK are not hidden. Laravel's ModelNotFoundException is also preserved for missing or incorrectly scoped threads.

Testing and quality

Run the complete local quality gate:

Or run checks independently:

The GitHub compatibility workflow covers PHP 8.2 through 8.5 across Laravel 11, 12, and 13 using each framework's supported PHP range.

Security

Please do not publish API keys, prompts containing secrets, or sensitive transcript data in issues. Report vulnerabilities privately using the process in SECURITY.md.

Changelog

See CHANGELOG.md for release history.

Credits

License

Laravel Chatbot is open-sourced software licensed under the MIT license.


All versions of laravel-chatbot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.29 || ^12.12 || ^13.0
openai-php/laravel Version ^0.20
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package halilcosdu/laravel-chatbot contains the following files

Loading the files please wait ...