PHPackages                             marcino0o/openai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. marcino0o/openai

ActiveLibrary[API Development](/categories/api)

marcino0o/openai
================

SDK for communication with open ai

1.1.1(2mo ago)066[1 PRs](https://github.com/marcino0o/openai/pulls)MITPHPPHP ^8.4CI passing

Since Oct 10Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/marcino0o/openai)[ Packagist](https://packagist.org/packages/marcino0o/openai)[ RSS](/packages/marcino0o-openai/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (19)Used By (0)

OpenAI PHP SDK (by @marcino0o)
==============================

[](#openai-php-sdk-by-marcino0o)

A lightweight, modern PHP (≥ 8.4) wrapper for the OpenAI API. Focused on simplicity and rapid integration for Chat Completions, with growing support for other endpoints.

---

[![Packagist Version](https://camo.githubusercontent.com/09e275f93843aa7601528feb2d17edca713ff3fc6ced0267afdcb78aaf8041a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617263696e6f306f2f6f70656e61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcino0o/openai)[![Packagist Downloads](https://camo.githubusercontent.com/b04d9b80afbbae7bdff85832cef52c739da5bedeb6c7006633f53efd55c636bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617263696e6f306f2f6f70656e61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcino0o/openai)[![GitHub Workflow Status](https://camo.githubusercontent.com/30f004843a7a908edd231f21cea72fa90423b6332b866f4c90c3d54807861ed5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617263696e6f306f2f6f70656e61692f72656c656173652e796d6c3f6272616e63683d6d61696e266c6162656c3d72656c65617365267374796c653d666c61742d737175617265)](https://github.com/marcino0o/openai/actions)[![License](https://camo.githubusercontent.com/883d16cc67378d5aad39344ef34a97277737e80d526c2ea2fedf2a2dcce31612/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d617263696e6f306f2f6f70656e61692e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/0877e32ed86ec32f000fbec9967019faa21e0e78f099987e1758fe27b893a5bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d626c75653f7374796c653d666c61742d737175617265)](https://www.php.net/)[![Tests](https://camo.githubusercontent.com/2cb9737d846d94da5d2fa660a362424c632be9f23b8bb31dd5df9df2867c85fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617263696e6f306f2f6f70656e61692f74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/marcino0o/openai/actions/workflows/tests.yml)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Usage](#usage)

    - [Chat Completions – Basics](#chat-completions--basics)
    - [System Role / Messages](#system-role--messages)
    - [Model Selection](#model-selection)
    - [Images](#images)
    - [Audio](#audio)
    - [Moderations](#moderations)
- [Supported Endpoints](#supported-endpoints)
- [Error Handling](#error-handling)
- [Retry / Timeout / Streaming](#retry--timeout--streaming)
- [Logging &amp; Telemetry](#logging--telemetry)
- [Testing](#testing)
- [Contributing](#contributing)
- [Versioning](#versioning)
- [License](#license)
- [FAQ](#faq)

---

Requirements
------------

[](#requirements)

- PHP 8.4+
- Composer

---

Installation
------------

[](#installation)

### From Packagist

[](#from-packagist)

```
composer require marcino0o/openai
```

---

Quick Start
-----------

[](#quick-start)

```
export OPENAI_API_KEY="sk-..."
```

```
