Download the PHP package mounirrquiba/openai without Composer
On this page you can find all versions of the php package mounirrquiba/openai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mounirrquiba/openai
More information about mounirrquiba/openai
Files in mounirrquiba/openai
Package openai
Short Description OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.
License MIT
Informations about the package openai
OpenAI API Client in PHP (community-maintained)
This library is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.
Installation
You can install the package via composer:
// PHP 8.0, 8.1, 8.2
Table of Contents
- Quick Start
- Keys
- Custom API URL
- Proxy
- Headers
- Services
- Models
- List models
- Retrieve model
- Completions
- Create completions
- Create stream completions
- Chat
- Create chat completion
- Create stream chat completion
- Edits
- Create edit
- Images
- Create image
- Create image edit
- Create image variation
- Embeddings
- Create embeddings
- Audio
- Create transcription
- Create translation
- Files
- List files
- Upload file
- Delete file
- Retrieve file
- Retrieve file content
- Fine-tunes
- Create fine-tune
- List fine-tunes
- Retrieve fine-tune
- Cancel fine-tune
- List fine-tune events
- List fine-tune events with stream
- Delete fine-tune model
- Moderations
- Create moderation
- Models
- Exceptions
- Tests
- Licence
Quick Start
Keys configuration
You can store you api key and organization key into your env
Powershell
Cmd
Linux or macOS
Alternatively you can set it in your code, you only need to do this once. If you have already put the variables in your env this step is not necessary
Custom API URL configuration
If you don't use OpenAI endpoint you can change it
Proxy configuration
Headers configuration
Back to top
Services
Models
Lists the currently available models, and provides basic information about each one such as the owner and availability.
Request (models)
Response (models)
Back to top
Model
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
Request (model)
Response (model)
Back to top
Completions
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
Create completions
Creates a completion for the provided prompt and parameters.
Request (Create completions)
Response (Create completions)
Back to top
Create stream completions
Creates a completion for the provided prompt and parameters with stream.
Request (Create stream completions)
Response (Create stream completions)
Back to top
Chat
Given a list of messages describing a conversation, the model will return a response.
Create chat completion
Creates a model response for the given chat conversation.
Request (Create chat completion)
Response (Create chat completion)
Back to top
Create stream chat completion
Creates a model response for the given chat conversation with stream.
Request (Create stream chat completion)
Response (Create stream chat completion)
Back to top
Edits
Creates a new edit for the provided input, instruction, and parameters.
Request (Edits)
Response (Edits)
Back to top
Images
Given a prompt and/or an input image, the model will generate a new image.
Images Generations
Creates an image given a prompt.
Request (Images Generations)
Response (Images Generations)
Back to top
Images Edits
Creates an edited or extended image given an original image and a prompt.
Request (Images Edits)
Response (Images Edits)
Back to top
Images Variations
Creates a variation of a given image.
Request (Images Variations)
Response (Images Variations)
Back to top
Embeddings
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. Creates an embedding vector representing the input text.
Request (Embeddings)
Response (Embeddings)
Back to top
Audio
Creates a new edit for the provided input, instruction, and parameters.
Audio Transcriptions
Transcribes audio into the input language.
Request (Audio Transcriptions)
Response (Audio Transcriptions)
Back to top
Audio Translations
Translates audio into into English.
Request (Audio Translations)
Response (Audio Transcriptions)
Back to top
Files
Files are used to upload documents that can be used with features like Fine-tuning.
List files
Returns a list of files that belong to the user's organization.
Request (List files)
Response (List files)
Back to top
Upload file
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
Request (Upload file)
Response (Upload file)
Delete file
Delete a file.
Request (Delete file)
Response (Delete file)
Back to top
Retrieve file
Returns information about a specific file.
Request (Retrieve file)
Response (Retrieve file)
Back to top
Retrieve file content
Returns the contents of the specified file
Request (Retrieve file content)
Response (Retrieve file content)
Back to top
Fine-tune
Manage fine-tuning jobs to tailor a model to your specific training data.
Create fine-tune
Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
Request (Create fine-tune)
Response (Create fine-tune)
Back to top
List fine-tunes
List your organization's fine-tuning jobs
Request (List fine-tunes)
Response (List fine-tunes)
Back to top
Retrieve fine-tune
Gets info about the fine-tune job.
Request (Retrieve fine-tune)
Response (Retrieve fine-tune)
Back to top
Cancel fine-tune
Immediately cancel a fine-tune job.
Request (Cancel fine-tune)
Response (Cancel fine-tune)
Back to top
List fine-tune events
Get fine-grained status updates for a fine-tune job.
Request (List fine-tune events)
Response (List fine-tune events)
Back to top
Delete fine-tune model
Delete a fine-tuned model. You must have the Owner role in your organization.
Request (Delete fine-tune model)
Response (Delete fine-tune model)
Back to top
Moderations
Given a input text, outputs if the model classifies it as violating OpenAI's content policy. Classifies if text violates OpenAI's Content Policy
Request (Moderations)
Response (Moderations)
Back to top
Exceptions
The provided code demonstrates a try-catch block for handling exceptions.
List of exceptions:
- FileNotFoundException: It is used to handle exceptions related to files that are not found or inaccessible.
- BadResponseException: It is used to handle exceptions related to bad or unexpected responses.
- InvalidParameterException: It is used to handle exceptions related to invalid parameters passed.
- RequiredParameterException: It is used to handle exceptions related to required parameters.
Back to top
Tests
Back to top
License
The MIT License (MIT)
Copyright (c) Mounir R'Quiba | https://www.linkedin.com/in/mounir-r-quiba-14aa84ba/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.