https://github.com/php-client/openai
PHP client for OpenAI API
https://github.com/php-client/openai
api client gpt openai php saloon sdk
Last synced: 4 months ago
JSON representation
PHP client for OpenAI API
- Host: GitHub
- URL: https://github.com/php-client/openai
- Owner: php-client
- License: mit
- Created: 2025-02-13T21:00:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-25T20:49:51.000Z (about 1 year ago)
- Last Synced: 2025-07-12T10:39:23.860Z (12 months ago)
- Topics: api, client, gpt, openai, php, saloon, sdk
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP client for OpenAI API.
This is a PHP client for the OpenAI API.
## Installation
Install the package via composer:
```bash
composer require php-client/openai
```
## Usage
```php
use PhpClient\OpenAI\OpenAI;
$openai = new OpenAI(
baseUrl: 'https://api.openai.com',
token: 'YOUR_API_TOKEN',
);
$response = $openai->api->chat()->createChatCompletion(
model: 'gpt-4o',
messages: [
['role' => 'user', 'content' => 'Hello'],
],
);
echo $response->json(key: 'choices.0.message.content');
// or
foreach ($response->json(key: 'choices') as $choice) {
echo $choice['message']['content'];
}
```
## List of available API methods
- Audio
- Create speech|transcription|translation
- Chat
- Create chat completion
- Embeddings
- Create embeddings
- Fine-tuning
- Create|Retrieve|Cancel fine-tuning job
- List fine-tuning jobs|events|checkpoints
- Batch
- Create|Retrieve|Cancel|List batch
- Files
- List files
- Upload|Retrieve|Delete file
- Retrieve file content
- Uploads
- Create|Complete|Cancel upload
- Add upload part
- Images
- Create image
- Create image edit|variation
- Models
- List models
- Retrieve model
- Delete fine-tuned model
- Moderations
- Create moderation
- LegacyCompletions
- Create completion
## Not implemented API methods (in development)
- Assistants
- Administration
- Realtime
- Legacy
## License
This package is released under the [MIT License](LICENSE.md).