Download the PHP package sanjarani/openai without Composer

On this page you can find all versions of the php package sanjarani/openai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openai

Sanjarani OpenAI Laravel Package

Latest Version on Packagist Total Downloads

A comprehensive Laravel 12 package for interacting with the OpenAI API. This package provides an easy-to-use interface for all major OpenAI features, including Chat Completions, Embeddings, Image Generation, Audio Transcription/Translation, File Management, Fine-tuning, Moderations, Models, and the powerful Assistants API with Vector Store support. It also includes advanced features like configurable caching, batching, and flexible API endpoint configuration for optimized performance and cost-efficiency.

Features

Requirements

Installation

You can install the package via Composer:

The package will automatically register its service provider and facade.

Next, publish the configuration file:

This will create a config/openai.php file in your application. You should add your OpenAI API Key and (optionally) Organization ID and Base URL to your .env file:

Configuration

The config/openai.php file allows you to configure various aspects of the package:

Configuring OpenAI-Beta Headers

To use features like Assistants API v2, you might need to send specific OpenAI-Beta headers. You can configure these in config/openai.php:

This setup allows you to enable beta features like Assistants API v2 by setting OPENAI_BETA_ASSISTANTS_VERSION=v2 in your .env file. The Client.php has been updated to automatically include these configured headers in all API requests.

Usage

The package provides a Facade for easy access to its functionalities.

Per-Request Base URL Override

All resource methods (e.g., OpenAI::chat()->create(...), OpenAI::embeddings()->create(...)) now accept an optional final string parameter to override the baseUrl for that specific request. This is useful if you need to target a different API endpoint for a particular call (e.g., a beta endpoint or a custom proxy).

If no baseUrlOverride is provided, the base_url from your config/openai.php (or its default https://api.openai.com/v1/) will be used.

Basic Example: Chat Completion

Streaming Chat Completion

Embeddings

Image Generation

Audio Transcription (Whisper)

Audio Speech (TTS)

Assistants API Example

(Ensure openai_beta_headers in config/openai.php is set correctly if using Assistants API v2, e.g., by setting OPENAI_BETA_ASSISTANTS_VERSION=v2 in your .env file.)

Vector Stores (with Assistants API)

(Ensure openai_beta_headers in config/openai.php is set correctly if using Assistants API v2.)

Caching

If caching is enabled in config/openai.php, responses for configured endpoints will be cached automatically.

Error Handling

The package throws specific exceptions for different types of API errors (as previously documented).

Testing

(As previously documented)

Contributing

(As previously documented)

License

(As previously documented)


This README provides a comprehensive overview. For specific API parameters and more detailed information, please refer to the official OpenAI API documentation.


All versions of openai with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^11.0|^12.0
illuminate/contracts Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sanjarani/openai contains the following files

Loading the files please wait ...