Download the PHP package erdum/php-open-ai-assistant-sdk without Composer
On this page you can find all versions of the php package erdum/php-open-ai-assistant-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download erdum/php-open-ai-assistant-sdk
More information about erdum/php-open-ai-assistant-sdk
Files in erdum/php-open-ai-assistant-sdk
Package php-open-ai-assistant-sdk
Short Description A PHP class for seamless interaction with the OpenAI Assistant API, enabling developers build powerful AI assistants capable of performing a variety of tasks.
License MIT
Informations about the package php-open-ai-assistant-sdk
OpenAI Assistant API PHP SDK
A PHP class for seamless interaction with the OpenAI Assistant API, enabling developers to build powerful AI assistants capable of performing a variety of tasks.
Table of Contents
- Installation
- Usage
- Reference
- Feedback
- License
Installation
Install with composer
Or install without composer on older PHP versions just clone the project in your working directory and require the OpenAIAssistant.php
Usage
Currently, this usage example does not contain any information about OpenAI Assistant API working for a better understanding of how OpenAI Assistant API works and its lifecycle please refer to the OpenAI documentation and look the Reference to see all the available methods.
How PHP functions will be called
Whatever function names you provide in the tools array will be called in your PHP environment accordingly by the Assistant API, for example in the below code function "get_account_balance" should be present in your PHP environment in order to be executed. If you want to run methods of an object or static methods of a class then you can provide an additional argument to the "execute_tools" method
Create a new Assistant
Reference
Constructor
Parameter | Type | Description |
---|---|---|
$api_key |
string |
Required. Your OpenAI API key. |
$assistant_id |
string |
Assistant ID (default = null ). |
$base_url |
string |
OpenAI API base URL (default = 'https://api.openai.com/v1'). |
$version_header |
string |
OpenAI API version header (default = 'OpenAI-Beta: assistants=v1'). |
Returns | void |
No return value. |
create_assistant
Parameter | Type | Description |
---|---|---|
$name |
string |
Name of the assistant. |
$instructions |
string |
Instructions for the assistant. |
$tools |
array |
Array of tools. |
Returns | string |
ID of the created assistant. |
modify_assistant
Parameter | Type | Description |
---|---|---|
$name |
string |
Name of the assistant. |
$instructions |
string |
Instructions for the assistant. |
$tools |
array |
Array of tools. |
Returns | string |
ID of the modified assistant. |
list_assistants
No parameters.
Returns | array |
List of available assistants. |
---|
create_thread
Parameter | Type | Description |
---|---|---|
$content |
string |
Content of the thread. |
$role |
string |
Role (default = 'user'). |
Returns | string |
ID of the created thread. |
get_thread
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
Returns | array |
Details of the thread. |
add_message
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
$content |
string |
Content of the message. |
$role |
string |
Role (default = 'user'). |
Returns | string |
ID of the added message. |
get_message
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
$message_id |
string |
Message ID. |
Returns | array |
Details of the message. |
list_thread_messages
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
Returns | array |
List of messages in the thread. |
run_thread
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
Returns | string |
ID of the thread run. |
execute_tools
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
$execution_id |
string |
Execution ID. |
$optional_object |
object |
Optional object. |
Returns | array |
Outputs of executed tools. |
submit_tool_outputs
Parameter | Type | Description |
---|---|---|
$thread_id |
string |
Thread ID. |
$execution_id |
string |
Execution ID. |
$outputs |
array |
Tool outputs array. |
Returns | string |
ID of the submitted tool outputs. |
Feedback
If you have any feedback, please reach out to us at [email protected]
License
All versions of php-open-ai-assistant-sdk with dependencies
ext-curl Version *