gitmyhub

client

PHP ★ 5.8k updated 2d ago

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.

A community PHP library for calling the OpenAI API, covering chat, images, audio, embeddings, fine-tuning, and more, installable with one Composer command and compatible with Azure's OpenAI endpoint.

PHPComposerOpenAI APIsetup: easycomplexity 2/5

This is a community-built PHP library that lets PHP applications talk to OpenAI's API. OpenAI is the company behind GPT-4 and other AI models, and their API lets developers send text or images to those models and get AI-generated responses back. This library handles all the technical details of making those API calls from PHP code, so you do not have to write the low-level networking yourself.

Installing the library takes one terminal command using Composer, which is the standard package manager for PHP projects. Once installed, you point it at your OpenAI API key and start sending requests. The simplest case is just a few lines: create a client, send a message, get a reply. The library also supports more advanced configuration, such as pointing it at a custom server address instead of OpenAI's default one, adding custom HTTP headers, or swapping in a different HTTP client if your project already uses one.

The library covers a wide range of OpenAI features. You can generate text responses, list or delete AI models, work with files, create and manage fine-tuned models, generate images, run moderation checks on text, create audio transcriptions, work with embeddings (numerical representations of text used in search and similarity tasks), and manage vector stores used for document search. It also supports the Responses and Conversations APIs for multi-turn chat interactions, and includes access to real-time session keys for live streaming use cases.

Azure is supported as a service backend, meaning teams already using Microsoft Azure's hosted version of OpenAI can point this same library at their Azure endpoint instead. The README includes a testing section covering how to write tests against the library without making real API calls each time.

The library is maintained by a small group of contributors and is funded through GitHub sponsorships. It requires PHP version 8.2 or newer. The full README is longer than what was shown.

Where it fits