An unofficial, zero-dependency Go client for the OpenAI API, covering Responses, Chat Completions, images, audio and more.
orhanerday/open-ai
A community-maintained PHP client for the OpenAI REST API, with streaming support and no third-party runtime dependencies.
- Stars
- 2,361
- Forks
- 292
- Open issues
- 0
- Last commit
- 16 days ago
What is it?
This library wraps the OpenAI REST API for PHP applications. It provides dedicated methods for chat completions, the Responses API, images, embeddings, audio, files, fine-tuning, moderation, vector stores, batches, uploads, realtime sessions, webhooks and organization usage reporting. Requests use PHP's native cURL and JSON extensions, so it needs PHP 7.4 or later and no other runtime packages.
For endpoints without a dedicated method, a generic request() method sends calls under the configured API prefix with JSON or multipart bodies. Streaming calls deliver server-sent event chunks to a callback. The base URL and API version can be changed, which allows use with OpenAI-compatible providers. Proxy, timeout, header and cURL option settings are also available.
Response handling includes a Response object with status, headers and JSON decoding, optional exceptions for HTTP errors, and automatic retries with exponential backoff for rate limits and selected server errors.
Key features
- 01Dedicated methods for chat, Responses, images, embeddings, audio, files and fine-tuning
- 02Streaming responses delivered through a callback
- 03Generic request() method for REST endpoints without dedicated methods
- 04Configurable base URL and API version for OpenAI-compatible providers
- 05Automatic retries for rate limits and selected server errors
- 06Webhook signature verification
Use cases
- Adding OpenAI chat or image generation to a Laravel, Symfony or CakePHP application
- Streaming model output to a browser through server-sent events
- Calling OpenAI-compatible providers from PHP by changing the base URL
- Managing files, batches or vector stores from PHP back-office scripts
Quick start
- 1
Install the library with Composer
composer require orhanerday/open-ai - 2
Set the OPENAI_API_KEY environment variable (Linux or macOS)
export OPENAI_API_KEY='your-api-key' - 3
Save the README example as example.php and run it
php example.php
Things to know
- PHP runtime security advisory: CVE-2026-109618 and CVE-2026-109619 affect PHP itself, so update PHP before use.
- WebSocket mode and mid-turn steering are not supported and need a separate client.
In collections
Topics
FAQ
- What is open-ai?
- A community-maintained PHP client for the OpenAI REST API, with streaming support and no third-party runtime dependencies. This library wraps the OpenAI REST API for PHP applications. It provides dedicated methods for chat completions, the Responses API, images, embeddings, audio, files, fine-tuning, moderation, vector stores, batches, uploads, realtime sessions, webhooks and organization usage reporting. Requests use PHP's native cURL and JSON extensions, so it needs PHP 7.4 or later and no other runtime packages.
- Is open-ai free to use? What license does it have?
- open-ai is open source under the MIT license. Check the license terms before using it in commercial products.
- Is open-ai still maintained?
- Actively maintained. The last commit to open-ai was on Oct 21, 2026.
- What can I use open-ai for?
- Adding OpenAI chat or image generation to a Laravel, Symfony or CakePHP application Streaming model output to a browser through server-sent events Calling OpenAI-compatible providers from PHP by changing the base URL Managing files, batches or vector stores from PHP back-office scripts
- How do I install open-ai?
- Install the library with Composer: composer require orhanerday/open-ai Set the OPENAI_API_KEY environment variable (Linux or macOS): export OPENAI_API_KEY='your-api-key' Save the README example as example.php and run it: php example.php
- Where can I get open-ai?
- The source code and installation instructions are on GitHub: https://github.com/orhanerday/open-ai
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Community-maintained Swift package wrapping the OpenAI public API, covering chat, responses, images, audio, embeddings and assistants.
Official TypeScript SDK for calling Anthropic's Claude API from server-side JavaScript and TypeScript applications.
A Python library giving one interface for chat, streaming, tool calls, and structured output across AI providers.
The official Python library for the OpenAI REST API, with sync and async clients and typed request and response models.
The official Go client library for the OpenAI REST API, covering Responses, Chat Completions, Realtime and more.