Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Chatgpt Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. 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).
  2. Publish assets/config/migrations:
    php artisan vendor:publish --provider="Naif\Chatgpt\ToolServiceProvider"
    php artisan migrate
    
  3. Add your OpenAI key. Most Naif tools read from config/chatgpt.php or env('OPENAI_API_KEY') — confirm which by reading the published config, since there's no documented convention here.
  4. Register the tool in app/Nova/NovaServiceProvider.php:
    public function tools()
    {
        return [new \Naif\Chatgpt\Chatgpt()];
    }
    
  5. Clear caches (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.

Implementation Patterns

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.

Gotchas and Tips

  • API key exposure. Naif tools historically read config at boot. Never commit the key; use OPENAI_API_KEY in .env and config:cache in production. Confirm the key isn't bundled into the compiled Vue JS.
  • Vendor-published migrations collide. The table name is almost certainly 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.
  • Nova version drift. With 3 stars and a single maintainer, compatibility is on you. Pin the version in composer.json ("naif/chatgpt": "1.0.*") and test Nova upgrades in a branch.
  • No tests, no CI. Assume the package is untested against your setup. Write a smoke test that hits the tool route with Nova's testing helpers before merging.
  • Error handling is thin. OpenAI 429s and 401s may surface as a generic Nova toast or an empty answer. Add Log::error around the service call, or override the tool's controller, to get actionable messages.
  • No streaming. Long answers appear all at once; the UI will look frozen. Set the request timeout in the tool component's axios config, and warn users.
  • Cost surface. Because every prompt is persisted, an inactive team can still accumulate a large table of prompts you're paying for. Add a retention job (e.g. ->where('created_at', '<', now()->subMonths(3))->delete()) and a prune command.
  • Extension points. The realistic ones are: publish config, publish views (--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.
  • Debugging checklist when the tool returns nothing: (1) 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect