naif/chatgpt
A Laravel package that integrates OpenAI's ChatGPT API into your PHP applications, offering a simple wrapper for sending prompts and receiving AI-generated responses. Note: limited documentation and low adoption, so review the source before production use.
This is a Nova-only tool, so treat it as an internal admin utility rather than a general ChatGPT SDK. The realistic first-use case is giving your team a searchable record of prompts and answers inside the Nova dashboard.
Minimal setup:
composer require naif/chatgpt (verify Nova version compatibility first — this is a low-adoption package, so check composer.json constraints against your Nova major version).php artisan vendor:publish --provider="Naif\Chatgpt\ToolServiceProvider"
php artisan migrate
config/chatgpt.php or env('OPENAI_API_KEY') — confirm which by reading the published config, since there's no documented convention here.app/Nova/NovaServiceProvider.php:
public function tools()
{
return [new \Naif\Chatgpt\Chatgpt()];
}
php artisan config:clear && php artisan nova:publish) and open the tool from the Nova sidebar.First thing to read: the published migration (to see the table shape and column names) and the tool's Tool.vue component — the Vue source is where the actual request lifecycle lives, and it's the fastest way to understand what gets persisted and when.
Knowledge-base / prompt-log pattern. The package's real value is the persisted Q&A table. Query it from a custom Nova resource or a plain Eloquent model if you want filtering, exporting, or Slack digests. Don't build reporting inside the tool's own Vue component — it isn't designed for it.
Per-user scoping. Wrap the underlying model with a global scope on user_id (if the migration stores it) so different teams don't see each other's prompts. If the migration lacks a user column, add one in a follow-up migration rather than editing the published one.
Config override instead of code edits. Point the config at a different model (gpt-4o vs gpt-3.5-turbo), temperature, and max tokens. Keep overrides in config/chatgpt.php (or your own config/ai.php) so you can swap providers later without touching vendor code.
Integration tip — queue it. If your team asks long prompts, wrap the service call in a job and store a status column, then have the Nova view poll or refresh. The stock tool is synchronous and will hit PHP's max_execution_time on slow OpenAI responses.
Testing seam. Bind the OpenAI client behind an interface in a service provider and use Http::fake() for the actual HTTP call. Because the package doesn't ship a contract, you'll need to add one yourself if you want meaningful tests.
Side-by-side with laravel/ai or openai-php/client. If you need streaming, function calling, or embeddings, use one of those directly. This package is a UI wrapper; fighting it for advanced features is a losing trade.
OPENAI_API_KEY in .env and config:cache in production. Confirm the key isn't bundled into the compiled Vue JS.chatgpt or questions. If you've already got a chatgpt table from another package (or a prior install), the migration will fail silently on migrate in some Laravel versions. Check php artisan migrate:status after publishing.composer.json ("naif/chatgpt": "1.0.*") and test Nova upgrades in a branch.Log::error around the service call, or override the tool's controller, to get actionable messages.->where('created_at', '<', now()->subMonths(3))->delete()) and a prune command.--tag=chatgpt-views), and swap the underlying model class via the container. Do not composer patch the vendor directory — you'll lose it on the next update, and this maintenance cadence guarantees updates will be rare but disruptive.OPENAI_API_KEY set and config:clear run; (2) php artisan migrate:status shows the tool's table; (3) network egress to api.openai.com not blocked; (4) tool registered in NovaServiceProvider::tools(); (5) check storage/logs/laravel.log for the raw exception, since surface error handling is minimal.How can I help you explore Laravel packages today?