chrisreedio/laravel-openai-sdk

OpenAI integration for Laravel via Saloon

dev-main 2024-04-15 20:35 UTC

README

Logo

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a SDK for the OpenAI API.

Note

This package is still in development and is not ready for production use.

It is proudly powered by Saloon by Sam CarrĂ©! đŸ¤ 

Installation

You can install the package via composer:

composer require chrisreedio/laravel-openai-sdk

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-openai-sdk-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-openai-sdk-config"

This is the contents of the published config file:

return [
    'max_per_page' => 100,
    'api_key' => env('OPENAI_API_KEY'),
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-openai-sdk-views"

Usage

use ChrisReedIO\OpenAI\Facades\OpenAI;

// Get a list of all the assistants
$assistants = OpenAI::assistants()->list()->collect()->all();

// or via a Lazy Collection
$assistants = OpenAI::assistants()->list()->collect();
$assistants->each(function ($assistant) {
    // Do something with the assistant
});

// Create a thread
$thread = OpenAI::threads()->create();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.