geekr/openai-laravel

Laravel OpenAI wrapper with suppoort for proxy

dev-master 2023-03-08 06:00 UTC

This package is auto-updated.

Last update: 2024-05-08 08:18:19 UTC


README

Laravel OpenAI Wrapper with support for proxy

Install:

composer require geekr/openai-laravel

Publish config file:

php artisan vendor:publish --provider="GeekrOpenAI\Laravel\ServiceProvider"

Edit OPENAI_* setting in .env:

OPENAI_API_KEY={your openai api key}
OPENAI_BASE_URI=open.aiproxy.xyz/v1

Usage:

use GeekrOpenAI\Laravel\Facades\OpenAI;

$response = OpenAI::chat()->create([
    'model' => 'gpt-3.5-turbo',
    'messages' => $messages
]);

$content = $response->choices[0]->message->content

Sample Project:

https://github.com/geekr-dev/geekchat

image