laravel  by openai-php

Laravel package for OpenAI API interaction

Created 2 years ago
3,505 stars

Top 13.9% on SourcePulse

GitHubView on GitHub
Project Summary

This package provides a PHP API client for interacting with the OpenAI API, specifically tailored for Laravel applications. It simplifies integrating powerful AI models like GPT into PHP-based web applications, benefiting developers seeking to leverage AI capabilities within their existing Laravel ecosystems.

How It Works

The package leverages the openai-php/client for core API interactions and provides a Laravel-specific facade for seamless integration. Configuration is managed via environment variables or a dedicated configuration file, allowing easy setup of API keys, organization IDs, and base URLs. The design prioritizes ease of use and testability, offering a fake() method for mocking API responses during development and testing.

Quick Start & Requirements

  • Install via Composer: composer require openai-php/laravel
  • Run artisan command: php artisan openai:install
  • Requires PHP 8.1+
  • OpenAI API Key and Organization ID (obtainable from OpenAI dashboard)
  • Configuration file: config/openai.php
  • Environment variables: OPENAI_API_KEY, OPENAI_ORGANIZATION

Highlighted Details

  • Provides a Laravel facade (OpenAI) for convenient API access.
  • Includes a fake() method for easy mocking of API responses in tests.
  • Supports configuration of API base URL and request timeouts.
  • Community-maintained with active sponsorship opportunities for developers.

Maintenance & Community

This is a community-maintained project with sponsorship opportunities for its core developers, Nuno Maduro and Sandro Gehri. For framework-agnostic usage, refer to the openai-php/client repository.

Licensing & Compatibility

Licensed under the MIT license, permitting commercial use and integration with closed-source applications.

Limitations & Caveats

The package relies on the underlying openai-php/client for feature set and model support. Specific limitations would be those inherent to the OpenAI API itself or the client library's implementation.

Health Check
Last Commit

2 weeks ago

Responsiveness

1 week

Pull Requests (30d)
7
Issues (30d)
0
Star History
62 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.