{"id":13400710,"url":"https://github.com/orhanerday/open-ai","last_synced_at":"2025-05-11T03:46:23.312Z","repository":{"id":39650980,"uuid":"440520058","full_name":"orhanerday/open-ai","owner":"orhanerday","description":"OpenAI PHP SDK : Most downloaded, forked, contributed, huge community supported, and used PHP (Laravel , Symfony, Yii, Cake PHP or any PHP framework) SDK for OpenAI GPT-3 and DALL-E. It also supports chatGPT-like streaming. (ChatGPT AI is supported)","archived":false,"fork":false,"pushed_at":"2025-03-12T12:05:15.000Z","size":2119,"stargazers_count":2339,"open_issues_count":30,"forks_count":302,"subscribers_count":43,"default_branch":"main","last_synced_at":"2025-05-11T03:45:57.936Z","etag":null,"topics":["cakephp","dall-e","dalle2","gpt-3","laravel","openai","openai-api","php","symfony","yii"],"latest_commit_sha":null,"homepage":"https://orhanerday.gitbook.io/openai-php-api-1/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orhanerday.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"orhanerday"}},"created_at":"2021-12-21T13:07:08.000Z","updated_at":"2025-05-08T10:03:04.000Z","dependencies_parsed_at":"2022-08-09T15:08:48.014Z","dependency_job_id":"d4039fda-3490-43c2-90c4-696889fcc09c","html_url":"https://github.com/orhanerday/open-ai","commit_stats":{"total_commits":195,"total_committers":25,"mean_commits":7.8,"dds":0.5025641025641026,"last_synced_commit":"d8c78fe2f5fed59e0ba458f90b5589ed9f13a367"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":"spatie/package-skeleton-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanerday%2Fopen-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanerday%2Fopen-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanerday%2Fopen-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanerday%2Fopen-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orhanerday","download_url":"https://codeload.github.com/orhanerday/open-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514555,"owners_count":21920334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","dall-e","dalle2","gpt-3","laravel","openai","openai-api","php","symfony","yii"],"created_at":"2024-07-30T19:00:54.822Z","updated_at":"2025-05-11T03:46:23.292Z","avatar_url":"https://github.com/orhanerday.png","language":"PHP","funding_links":["https://github.com/sponsors/orhanerday","https://www.buymeacoffee.com/orhane","https://patreon.com/orhann"],"categories":["SDK","Awesome PHP Open AI Projects","LLMs \u0026 AI APIs","PHP","Unity","SDK, Libraries, Frameworks","精选开源项目合集","A01_文本生成_文本对话","LLM Clients \u0026 Adapters"],"sub_categories":["3P SDK","Recommended core stack","Other sdk/libraries","GTP编程语言客户端","大语言对话模型及数据"],"readme":"# OpenAI API Client in PHP\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n## If you want to ensure this project stays alive and continues to faster improve, please please consider supporting it. Your help means a lot. Thank you!\n* [Buy me a coffee](https://www.buymeacoffee.com/orhane)\n* [Patreon](https://patreon.com/orhann)\n\u003e ### ChatGPT API is currently supported, [click here](#chat-as-known-as-chatgpt-api) for the implementation introductions.\n\n\u003cbr /\u003e\n\n*A message from creator,\u003cbr /\u003eThank you for visiting the __@orhanerday/open-ai__ repository! If you find this repository helpful or useful, we encourage you to **star** it\non GitHub. Starring a repository is a way to show your support for the project. It also helps to increase the visibility\nof the project and to let the community know that it is valuable. Thanks again for your support and we hope you find the\nrepository useful! \u003cbr /\u003e\u003cbr /\u003e Orhan*\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/orhanerday/open-ai.svg?style=flat-square)](https://packagist.org/packages/orhanerday/open-ai)\n[![Total Downloads](https://img.shields.io/packagist/dt/orhanerday/open-ai.svg?style=flat-square)](https://packagist.org/packages/orhanerday/open-ai)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cimg src=\"./openai-elephpant.svg\" width=\"1250\" height=\"300\" alt=\"orhanerday-open-ai-logo\"\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n# Featured in\n\n\n[![Jetbrains Blog](https://user-images.githubusercontent.com/22305274/222431781-86591161-ccd5-4889-bd80-97a0fd0fdf0d.png)](https://blog.jetbrains.com/phpstorm/2022/12/php-annotated-december-2022/#:~:text=orhanerday/open%2Dai%20%E2%80%93%20A%20PHP%20SDK%20for%20accessing%20the%20OpenAI%20GPT%2D3%20API)\n\n[![Laravel News](https://user-images.githubusercontent.com/22305274/222430084-be097d59-e6bc-408d-8adb-7b751d5a05b2.png)](https://laravel-news.com/openai-sdk-for-php)\n\n[![日思录](https://user-images.githubusercontent.com/22305274/222431699-f3a8a146-e27c-4fe3-8c93-1d762559752f.png)](http://tubring.cn/articles/59)\n\n[![logo_new](https://github.com/orhanerday/open-ai/assets/22305274/398b3a1e-7323-46f3-8a53-a9f115cf2281)](https://site-analyzer.ru/articles/openai-gpt-3-first-samples/)\n\n\n\n# Comparison With Other Packages\n\n| Project Name           | Required PHP Version (Lower is better) | Description                                                                                                                                                | Type (Official / Community) | Support                                                                                                                                  |\n|------------------------|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| **orhanerday/open-ai** | **PHP 7.4+**                           | **Most downloaded, forked, contributed, huge community supported, and used PHP SDK for OpenAI GPT-3 and DALL-E. It also supports chatGPT-like streaming.** | Community                   | Available, ([Community driven Discord Server](https://discord.gg/xpGUD528XJ) or personal mail [orhann@duck.com](mailto:orhann@duck.com)) |\n| openai-** */c****t     | PHP 8.1+                               | OpenAI PHP API client.                                                                                                                                     | Community                   | -                                                                                                                                        |\n\n\n\u003cbr /\u003e\n\n## About this package\n\nFully open-source and secure community-maintained, PHP SDK for accessing the OpenAI GPT-3 API.\n\n\u003e #### For more information, you can read laravel news [blog post](https://laravel-news.com/openai-sdk-for-php).\n\u003e #### Free support is available. [Join our discord server](#join-our-discord-server)\n\u003e #### To get started with this package, you'll first want to be familiar with the [OpenAI API documentation](https://platform.openai.com/docs/overview) and [examples](https://platform.openai.com/docs/examples). Also you can get help from our discord channel that called [#api-support](https://discord.gg/R9CpVUdqQR)\n\n## News\n\n- orhanerday/open-ai added to community libraries php [section](https://platform.openai.com/docs/libraries/php).\n- orhanerday/open-ai featured\n  on [PHPStorm blog post](https://blog.jetbrains.com/phpstorm/2022/12/php-annotated-december-2022/#:~:text=orhanerday/open%2Dai%20%E2%80%93%20A%20PHP%20SDK%20for%20accessing%20the%20OpenAI%20GPT%2D3%20API),\n  thanks JetBrains!\n\n\u003e Requires PHP 7.4+\n\n## Join our discord server\n\n![Discord Banner 2](https://discordapp.com/api/guilds/1047074572488417330/widget.png?style=banner2)\n\n[Click here to join the Discord server](https://discord.gg/xpGUD528XJ)\n\n## Support this project\n\nAs you may know, OpenAI PHP is an open-source project wrapping tool for OpenAI. We rely on the support of our community\nto continue developing and maintaining the project, and one way that you can help is by making a donation.\n\nDonations allow us to cover expenses such as hosting costs(for testing), development tools, and other resources that are\nnecessary to keep the project running smoothly. Every contribution, no matter how small, helps us to continue improving\nOpenAI PHP for everyone.\n\nIf you have benefited from using OpenAI PHP and would like to support its continued development, we would greatly\nappreciate a donation of any amount. You can make a donation through;\n\n* [Buy me a coffee](https://www.buymeacoffee.com/orhane)\n* [Patreon](https://patreon.com/orhann)\n\nThank you for considering a donation to Orhanerday/OpenAI PHP SDK. Your support is greatly appreciated and helps to\nensure that the project can continue to grow and improve.\n\n*Sincerely,*\n\n**Orhan Erday** / Creator.\n\n# Documentation\nPlease visit https://orhanerday.gitbook.io/openai-php-api-1/\n\n# Endpoint Support\n\n- Chat\n    - [x] [ChatGPT API](#chat-as-known-as-chatgpt-api)\n- Models\n    - [x] [List models](https://platform.openai.com/docs/api-reference/models/list)\n    - [x] [Retrieve model](https://platform.openai.com/docs/api-reference/models/retrieve)\n- Completions\n    - [x] [Create completion](https://platform.openai.com/docs/api-reference/completions/create)\n- Edits\n    - [x] [Create edits](https://platform.openai.com/docs/api-reference/edits/create)\n- Images\n    - [x] [Create image](https://platform.openai.com/docs/api-reference/images/create)\n    - [x] [Create image edit](https://platform.openai.com/docs/api-reference/images/create-edit)\n    - [x] [Create image variation](https://platform.openai.com/docs/api-reference/images/create-variation)\n- Embeddings\n    - [x] [Create embeddings](https://platform.openai.com/docs/api-reference/embeddings/create)\n- Audio\n    - [x] [Text to Speech (TTS)](https://platform.openai.com/docs/guides/text-to-speech)\n    - [x] [Create transcription](https://platform.openai.com/docs/api-reference/audio/create)\n    - [x] [Create translation](https://platform.openai.com/docs/api-reference/audio/create)\n- Files\n    - [x] [List files](https://platform.openai.com/docs/api-reference/files/list)\n    - [x] [Upload file](https://platform.openai.com/docs/api-reference/files/upload)\n    - [x] [Delete file](https://platform.openai.com/docs/api-reference/files/delete)\n    - [x] [Retrieve file](https://platform.openai.com/docs/api-reference/files/retrieve)\n    - [x] [Retrieve file content](https://platform.openai.com/docs/api-reference/files/retrieve-content)\n- Fine-tunes\n    - [x] [Create fine-tune (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/create)\n    - [x] [List fine-tunes (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/list)\n    - [x] [Retrieve fine-tune (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/retrieve)\n    - [x] [Cancel fine-tune (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/cancel)\n    - [x] [List fine-tune events (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/events)\n    - [x] [Delete fine-tune model (beta)](https://platform.openai.com/docs/api-reference/fine-tunes/delete-model)\n- Moderation\n    - [x] [Create moderation](https://platform.openai.com/docs/api-reference/moderations/create)\n- ~~Engines~~ *(deprecated)*\n    - ~~[List engines](https://platform.openai.com/docs/api-reference/engines/list)~~\n    - ~~[Retrieve engine](https://platform.openai.com/docs/api-reference/engines/retrieve)~~\n- Assistants (beta)\n    - [x] [Create assistant](https://platform.openai.com/docs/api-reference/assistants/createAssistant)\n    - [x] [Retrieve assistant](https://platform.openai.com/docs/api-reference/assistants/getAssistant)\n    - [x] [Modify assistant](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)\n    - [x] [Delete assistant](https://platform.openai.com/docs/api-reference/assistants/deleteAssistant)\n    - [x] [Lists assistants](https://platform.openai.com/docs/api-reference/assistants/listAssistants)\n    - [x] [Create assistant file](https://platform.openai.com/docs/api-reference/assistants/createAssistantFile)\n    - [x] [Retrieve assistant file](https://platform.openai.com/docs/api-reference/assistants/getAssistantFile)\n    - [x] [Delete assistant file](https://platform.openai.com/docs/api-reference/assistants/deleteAssistantFile)\n    - [x] [List assistant files](https://platform.openai.com/docs/api-reference/assistants/listAssistantFiles)\n- Threads (beta)\n    - [x] [Create thread](https://platform.openai.com/docs/api-reference/threads/createThread)\n    - [x] [Retrieve thread](https://platform.openai.com/docs/api-reference/threads/getThread)\n    - [x] [Modify thread](https://platform.openai.com/docs/api-reference/threads/modifyThread)\n    - [x] [Delete thread](https://platform.openai.com/docs/api-reference/threads/deleteThread)\n- Messages (beta)\n    - [x] [Create message](https://platform.openai.com/docs/api-reference/messages/createMessage)\n    - [x] [Retrieve message](https://platform.openai.com/docs/api-reference/messages/getMessage)\n    - [x] [Modify message](https://platform.openai.com/docs/api-reference/messages/modifyMessage)\n    - [x] [Lists messages](https://platform.openai.com/docs/api-reference/messages/listMessages)\n    - [x] [Retrieve message file](https://platform.openai.com/docs/api-reference/messages/getMessageFile)\n    - [x] [List message files](https://platform.openai.com/docs/api-reference/messages/listMessageFiles)\n- Runs (beta)\n    - [x] [Create run](https://platform.openai.com/docs/api-reference/runs/createRun)\n    - [x] [Retrieve run](https://platform.openai.com/docs/api-reference/runs/getRun)\n    - [x] [Modify run](https://platform.openai.com/docs/api-reference/runs/modifyRun)\n    - [x] [Lists runs](https://platform.openai.com/docs/api-reference/runs/listRuns)\n    - [x] [Submit tool outputs](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)\n    - [x] [Cancel run](https://platform.openai.com/docs/api-reference/runs/cancelRun)\n    - [x] [Create thread and run](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun)\n    - [x] [Retrieve run step](https://platform.openai.com/docs/api-reference/runs/getRunStep)\n    - [x] [List run steps](https://platform.openai.com/docs/api-reference/runs/listRunSteps)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require orhanerday/open-ai\n```\n\n## Quick Start ⚡\n\nBefore you get starting, you should set OPENAI_API_KEY as ENV key, and set OpenAI key as env value with the following\ncommands;\n\n_Powershell_\n\n```powershell\n$Env:OPENAI_API_KEY = \"sk-gjtv.....\"\n```\n\n_Cmd_\n\n```cmd\nset OPENAI_API_KEY=sk-gjtv.....\n```\n\n_Linux or macOS_\n\n```shell\nexport OPENAI_API_KEY=sk-gjtv.....\n```\n\n\u003e Getting issues while setting up env? Please read\n\u003e the [article](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety) or you can check\n\u003e my [StackOverflow answer](https://stackoverflow.com/a/73904271/15196622) for the Windows® ENV setup.\n\nCreate your `index.php` file and paste the following code part into the file.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.\n\nuse Orhanerday\\OpenAi\\OpenAi;\n\n$open_ai_key = getenv('OPENAI_API_KEY');\n$open_ai = new OpenAi($open_ai_key);\n\n$chat = $open_ai-\u003echat([\n   'model' =\u003e 'gpt-3.5-turbo',\n   'messages' =\u003e [\n       [\n           \"role\" =\u003e \"system\",\n           \"content\" =\u003e \"You are a helpful assistant.\"\n       ],\n       [\n           \"role\" =\u003e \"user\",\n           \"content\" =\u003e \"Who won the world series in 2020?\"\n       ],\n       [\n           \"role\" =\u003e \"assistant\",\n           \"content\" =\u003e \"The Los Angeles Dodgers won the World Series in 2020.\"\n       ],\n       [\n           \"role\" =\u003e \"user\",\n           \"content\" =\u003e \"Where was it played?\"\n       ],\n   ],\n   'temperature' =\u003e 1.0,\n   'max_tokens' =\u003e 4000,\n   'frequency_penalty' =\u003e 0,\n   'presence_penalty' =\u003e 0,\n]);\n\n\nvar_dump($chat);\necho \"\u003cbr\u003e\";\necho \"\u003cbr\u003e\";\necho \"\u003cbr\u003e\";\n// decode response\n$d = json_decode($chat);\n// Get Content\necho($d-\u003echoices[0]-\u003emessage-\u003econtent);\n```\n\n_Run the server with the following command_\n\n```shell\nphp -S localhost:8000 -t .\n```\n\n## NVIDIA NIM INTEGRATION\n\norhanerday/open-ai supports Nvidia NIM. The below example is MixtralAI. Check https://build.nvidia.com/explore/discover for more examples.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.\n\nuse Orhanerday\\OpenAi\\OpenAi;\n\n$nvidia_ai_key = getenv('NVIDIA_AI_API_KEY');\nerror_log($open_ai_key);\n$open_ai = new OpenAi($nvidia_ai_key);\n$open_ai-\u003esetBaseURL(\"https://integrate.api.nvidia.com\");\n$chat = $open_ai-\u003echat([\n    'model' =\u003e 'mistralai/mixtral-8x7b-instruct-v0.1',\n    'messages' =\u003e [[\"role\" =\u003e \"user\", \"content\" =\u003e \"Write a limmerick about the wonders of GPU computing.\"]],\n    'temperature' =\u003e 0.5,\n    'max_tokens' =\u003e 1024,\n    'top_p' =\u003e 1,\n]);\n\nvar_dump($chat);\necho \"\u003cbr\u003e\";\necho \"\u003cbr\u003e\";\necho \"\u003cbr\u003e\";\n// decode response\n$d = json_decode($chat);\n// Get Content\necho ($d-\u003echoices[0]-\u003emessage-\u003econtent);\n\n```\n\n\n## Usage\n\n### Load your key from an environment variable.\n\n\u003e According to the following code `$open_ai` is the base variable for all open-ai operations.\n\n```php\nuse Orhanerday\\OpenAi\\OpenAi;\n\n$open_ai = new OpenAi(env('OPEN_AI_API_KEY'));\n```\n\n## Requesting organization\n\nFor users who belong to multiple organizations, you can pass a header to specify which organization is used for an API\nrequest.\nUsage from these API requests will count against the specified organization's subscription quota.\n\n````php\n$open_ai_key = getenv('OPENAI_API_KEY');\n$open_ai = new OpenAi($open_ai_key);\n$open_ai-\u003esetORG(\"org-IKN2E1nI3kFYU8ywaqgFRKqi\");\n````\n\n## Base URL\n\nYou can specify Origin URL with `setBaseURL()` method;\n\n````php\n$open_ai_key = getenv('OPENAI_API_KEY');\n$open_ai = new OpenAi($open_ai_key,$originURL);\n$open_ai-\u003esetBaseURL(\"https://ai.example.com/\");\n````\n\n## Use Proxy\n\nYou can use some proxy servers for your requests api;\n\n````php\n$open_ai-\u003esetProxy(\"http://127.0.0.1:1086\");\n````\n\n## Set header\n\n ```php\n$open_ai-\u003esetHeader([\"Connection\"=\u003e\"keep-alive\"]);\n```\n\n## Get cURL request info\n\n\u003e ### !!! WARNING:Your API key will expose if you add this method to your code, therefore remove the method before deployment. Be careful !\nYou can get cURL info after the request.\n\n````php\n$open_ai = new OpenAi($open_ai_key);\necho $open_ai-\u003elistModels(); // you should execute the request FIRST!\nvar_dump($open_ai-\u003egetCURLInfo()); // You can call the request\n````\n\n## Chat (as known as ChatGPT API)\n\nGiven a chat conversation, the model will return a chat completion response.\n\n ```php\n$complete = $open_ai-\u003echat([\n    'model' =\u003e 'gpt-3.5-turbo',\n    'messages' =\u003e [\n        [\n            \"role\" =\u003e \"system\",\n            \"content\" =\u003e \"You are a helpful assistant.\"\n        ],\n        [\n            \"role\" =\u003e \"user\",\n            \"content\" =\u003e \"Who won the world series in 2020?\"\n        ],\n        [\n            \"role\" =\u003e \"assistant\",\n            \"content\" =\u003e \"The Los Angeles Dodgers won the World Series in 2020.\"\n        ],\n        [\n            \"role\" =\u003e \"user\",\n            \"content\" =\u003e \"Where was it played?\"\n        ],\n    ],\n    'temperature' =\u003e 1.0,\n    'max_tokens' =\u003e 4000,\n    'frequency_penalty' =\u003e 0,\n    'presence_penalty' =\u003e 0,\n]);\n```\n\n## Accessing the Element\n\n```php\n\u003c?php\n// Dummy Response For Chat API\n$j = '\n{\n   \"id\":\"chatcmpl-*****\",\n   \"object\":\"chat.completion\",\n   \"created\":1679748856,\n   \"model\":\"gpt-3.5-turbo-0301\",\n   \"usage\":{\n      \"prompt_tokens\":9,\n      \"completion_tokens\":10,\n      \"total_tokens\":19\n   },\n   \"choices\":[\n      {\n         \"message\":{\n            \"role\":\"assistant\",\n            \"content\":\"This is a test of the AI language model.\"\n         },\n         \"finish_reason\":\"length\",\n         \"index\":0\n      }\n   ]\n}\n';\n\n// decode response\n$d = json_decode($j);\n\n// Get Content\necho($d-\u003echoices[0]-\u003emessage-\u003econtent);\n```\n\n\u003e ### Related: [ChatGPT Clone Project](#chatgpt-clone-project)\n\n## Completions\n\nGiven a prompt, the model will return one or more predicted completions, and can also return the probabilities of\nalternative tokens at each position.\n\n ```php\n$complete = $open_ai-\u003ecompletion([\n    'model' =\u003e 'gpt-3.5-turbo-instruct',\n    'prompt' =\u003e 'Hello',\n    'temperature' =\u003e 0.9,\n    'max_tokens' =\u003e 150,\n    'frequency_penalty' =\u003e 0,\n    'presence_penalty' =\u003e 0.6,\n]);\n```\n\n### Stream Example\n\nThis feature might sound familiar from [ChatGPT](https://chat.openai.com/chat).\n\n\u003chr\u003e\n\n#### ChatGPT Clone Project\n\nVideo of demo:\n\nhttps://user-images.githubusercontent.com/22305274/219878695-c76a58c0-5081-402c-a1b5-2b1fd971735a.mp4\n\nChatGPT clone is a simple web application powered by the OpenAI library and built with PHP. It allows users to chat with\nan AI language model that responds in real-time. Chat history is saved using cookies, and the project requires the use\nof an API key and enabled SQLite3.\n\nUrl of The ChatGPT-Clone Repo https://github.com/orhanerday/ChatGPT\n\n\u003chr\u003e\n\nWhether to stream back partial progress. If set, tokens will be sent as\ndata-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)\nas they become available, with the stream terminated by a data: [DONE] message.\n\n ````php\n$open_ai = new OpenAi(env('OPEN_AI_API_KEY'));\n\n$opts = [\n    'prompt' =\u003e \"Hello\",\n    'temperature' =\u003e 0.9,\n    \"max_tokens\" =\u003e 150,\n    \"frequency_penalty\" =\u003e 0,\n    \"presence_penalty\" =\u003e 0.6,\n    \"stream\" =\u003e true,\n];\n\nheader('Content-type: text/event-stream');\nheader('Cache-Control: no-cache');\n\n$open_ai-\u003ecompletion($opts, function ($curl_info, $data) {\n    echo $data . \"\u003cbr\u003e\u003cbr\u003e\";\n    echo PHP_EOL;\n    ob_flush();\n    flush();\n    return strlen($data);\n});\n\n````\n\nAdd this part inside `\u003cbody\u003e` of the HTML\n\n ````php\n\n\u003cdiv id=\"divID\"\u003eHello\u003c/div\u003e\n\u003cscript\u003e\n    var eventSource = new EventSource(\"/\");\n    var div = document.getElementById('divID');\n\n\n    eventSource.onmessage = function (e) {\n       if(e.data == \"[DONE]\")\n       {\n           div.innerHTML += \"\u003cbr\u003e\u003cbr\u003eHello\";\n       }\n        div.innerHTML += JSON.parse(e.data).choices[0].text;\n    };\n    eventSource.onerror = function (e) {\n        console.log(e);\n    };\n\u003c/script\u003e\n````\n\nYou should see a response like the in video;\n\nhttps://user-images.githubusercontent.com/22305274/209847128-f72c9345-dd34-46f0-bbc5-daf1d7b6121f.mp4\n\n## Edits\n\nCreates a new edit for the provided input, instruction, and parameters\n\n ```php\n    $result = $open_ai-\u003ecreateEdit([\n        \"model\" =\u003e \"text-davinci-edit-001\",\n        \"input\" =\u003e \"What day of the wek is it?\",\n        \"instruction\" =\u003e \"Fix the spelling mistakes\",\n    ]);\n```\n\n## Images (DALL·E)\n\n\u003e All DALL·E Examples available in this [repo](https://github.com/orhanerday/DALLE-Examples).\n\nGiven a prompt, the model will return one or more generated images as urls or base64 encoded.\n\n### Create image\n\nCreates an image given a prompt.\n\n ```php\n$complete = $open_ai-\u003eimage([\n    \"prompt\" =\u003e \"A cat drinking milk\",\n    \"n\" =\u003e 1,\n    \"size\" =\u003e \"256x256\",\n    \"response_format\" =\u003e \"url\",\n]);\n```\n\n### Create image edit\n\nCreates an edited or extended image given an original image and a prompt.\n\u003e You need HTML upload for image edit or variation? Please\n\u003e check [DALL·E Examples](https://github.com/orhanerday/DALLE-Examples)\n\n````php\n$otter = curl_file_create(__DIR__ . './files/otter.png');\n$mask = curl_file_create(__DIR__ . './files/mask.jpg');\n\n$result = $open_ai-\u003eimageEdit([\n    \"image\" =\u003e $otter,\n    \"mask\" =\u003e $mask,\n    \"prompt\" =\u003e \"A cute baby sea otter wearing a beret\",\n    \"n\" =\u003e 2,\n    \"size\" =\u003e \"1024x1024\",\n]);\n````\n\n### Create image variation\n\nCreates a variation of a given image.\n\n````php\n$otter = curl_file_create(__DIR__ . './files/otter.png');\n\n$result = $open_ai-\u003ecreateImageVariation([\n    \"image\" =\u003e $otter,\n    \"n\" =\u003e 2,\n    \"size\" =\u003e \"256x256\",\n]);\n````\n\n## Searches\n\n**_(Deprecated)_**\n\u003e This endpoint is deprecated and will be removed on December 3rd, 2022\n\u003e OpenAI developed new methods with better\n\u003e performance. [Learn more.](https://help.openai.com/en/articles/6272952-search-transition-guide)\n\nGiven a query and a set of documents or labels, the model ranks each document based on its semantic similarity to the\nprovided query.\n\n```php\n$search = $open_ai-\u003esearch([\n    'engine' =\u003e 'ada',\n    'documents' =\u003e ['White House', 'hospital', 'school'],\n    'query' =\u003e 'the president',\n]);\n```\n\n## Embeddings\n\nGet a vector representation of a given input that can be easily consumed by machine learning models and algorithms.\n\nRelated guide: [Embeddings](https://platform.openai.com/docs/guides/embeddings)\n\n### Create embeddings\n\n```php\n$result = $open_ai-\u003eembeddings([\n    \"model\" =\u003e \"text-similarity-babbage-001\",\n    \"input\" =\u003e \"The food was delicious and the waiter...\"\n]);\n```\n\n## Answers\n\n**_(Deprecated)_**\n\n\u003e This endpoint is deprecated and will be removed on December 3rd, 2022\n\u003e We’ve developed new methods with better\n\u003e performance. [Learn more](https://help.openai.com/en/articles/6233728-answers-transition-guide).\n\nGiven a question, a set of documents, and some examples, the API generates an answer to the question based on the\ninformation in the set of documents. This is useful for question-answering applications on sources of truth, like\ncompany documentation or a knowledge base.\n\n  ```php\n$answer = $open_ai-\u003eanswer([\n    'documents' =\u003e ['Puppy A is happy.', 'Puppy B is sad.'],\n    'question' =\u003e 'which puppy is happy?',\n    'search_model' =\u003e 'ada',\n    'model' =\u003e 'curie',\n    'examples_context' =\u003e 'In 2017, U.S. life expectancy was 78.6 years.',\n    'examples' =\u003e [['What is human life expectancy in the United States?', '78 years.']],\n    'max_tokens' =\u003e 5,\n    'stop' =\u003e [\"\\n\", '\u003c|endoftext|\u003e'],\n]);\n```\n\n## Classifications\n\n**_(Deprecated)_**\n\u003e This endpoint is deprecated and will be removed on December 3rd, 2022\n\u003e OpenAI developed new methods with better\n\u003e performance. [Learn more.](https://help.openai.com/en/articles/6272941-classifications-transition-guide)\n\nGiven a query and a set of labeled examples, the model will predict the most likely label for the query. Useful as a\ndrop-in replacement for any ML classification or text-to-label task.\n\n ```php\n$classification = $open_ai-\u003eclassification([\n    'examples' =\u003e [\n        ['A happy moment', 'Positive'],\n        ['I am sad.', 'Negative'],\n        ['I am feeling awesome', 'Positive'],\n    ],\n    'labels' =\u003e ['Positive', 'Negative', 'Neutral'],\n    'query' =\u003e 'It is a raining day =\u003e(',\n    'search_model' =\u003e 'ada',\n    'model' =\u003e 'curie',\n]);\n```\n\n## Content Moderations\n\nGiven a input text, outputs if the model classifies it as violating OpenAI's content policy.\n\n```php\n$flags = $open_ai-\u003emoderation([\n    'input' =\u003e 'I want to kill them.'\n]);\n```\n\nKnow more about Content Moderations here: [OpenAI Moderations](https://platform.openai.com/docs/api-reference/moderations)\n\n## List engines\n\n**_(Deprecated)_**\n\n\u003e The Engines endpoints are deprecated.\n\u003e Please use their replacement, [Models](#list-models), instead. [Learn more](TODO?).\n\nLists the currently available engines, and provides basic information about each one such as the owner and availability.\n\n ```php\n$engines = $open_ai-\u003eengines();\n```\n\n## Audio\n\n### Text To Speech (TTS)\n\n```php\n\n$result = $open_ai-\u003etts([\n    \"model\" =\u003e \"tts-1\", // tts-1-hd\n    \"input\" =\u003e \"I'm going to use the stones again. Hey, we'd be going in short-handed, you know\",\n    \"voice\" =\u003e \"alloy\", // echo, fable, onyx, nova, and shimmer\n]);\n\n// Save audio file\nfile_put_contents('tts-result.mp3', $result);\n```\n\n### Create Transcription\n\nTranscribes audio into the input language.\n\n```php\n$c_file = curl_file_create(__DIR__ . '/files/en-marvel-endgame.m4a');\n\n$result = $open_ai-\u003etranscribe([\n    \"model\" =\u003e \"whisper-1\",\n    \"file\" =\u003e $c_file,\n]);\n```\n#### Response\n\n```json\n{\n  \"text\": \"I'm going to use the stones again. Hey, we'd be going in short-handed, you know. Look, he's still got the stones, so... So let's get them. Use them to bring everyone back. Just like that? Yeah, just like that. Even if there's a small chance that we can undo this, I mean, we owe it to everyone who's not in this room to try. If we do this, how do we know it's going to end any differently than it did before? Because before you didn't have me. Hey, little girl, everybody in this room is about that superhero life. And if you don't mind my asking, where the hell have you been all this time? There are a lot of other planets in the universe. But unfortunately, they didn't have you guys. I like this one. Let's go get this son of a bitch.\"\n}\n```\n\n### Create Translation\n\nTranslates audio into English.\n\n_I use Turkish voice for translation thanks to famous science YouTuber [Barış Özcan](https://youtu.be/r2dQgdktUJg?t=90)_\n\n```php\n$c_file = curl_file_create(__DIR__ . '/files/tr-baris-ozcan-youtuber.m4a');\n\n$result = $open_ai-\u003etranslate([\n    \"model\" =\u003e \"whisper-1\",\n    \"file\" =\u003e $c_file,\n]);\n```\n#### Response\n\n```json\n{\n  \"text\": \"GPT-3. Last month, the biggest leap in the world of artificial intelligence in recent years happened silently. Maybe the biggest leap of all time. GPT-3's beta version was released by OpenAI. When you hear such a sentence, you may think, what kind of leap is this? But be sure, this is the most advanced language model with the most advanced language model with the most advanced language ability. It can answer these artificial intelligence questions, it can translate and even write poetry. Those who have gained access to the API or API of GPT-3 have already started to make very interesting experiments. Let's look at a few examples together. Let's start with an example of aphorism. This site produces beautiful words that you can tweet. Start to actually do things with your words instead of just thinking about them.\"\n}\n```\n\n #### Need HTML upload for audio? Check [this](#upload-file-with-html-form) section and change api references. Example :\n\n```php\n...\n    echo $open_ai-\u003etranslate(\n        [\n            \"purpose\" =\u003e \"answers\",\n            \"file\" =\u003e $c_file,\n        ]\n    );\n...\n// OR\n...\n    echo $open_ai-\u003etranscribe(\n        [\n            \"purpose\" =\u003e \"answers\",\n            \"file\" =\u003e $c_file,\n        ]\n    );\n...\n```\n\n## Files\n\nFiles are used to upload documents that can be used across features like Answers, Search, and Classifications\n\n### List files\n\nReturns a list of files that belong to the user's organization.\n\n```php\n$files = $open_ai-\u003elistFiles();\n```\n\n### Upload file\n\nUpload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the\nfiles uploaded by one organization can be up to 1 GB. Please contact OpenAI if you need to increase the storage limit.\n\n```php\n$c_file = curl_file_create(__DIR__ . 'files/sample_file_1.jsonl');\n$result = $open_ai-\u003euploadFile([\n            \"purpose\" =\u003e \"answers\",\n            \"file\" =\u003e $c_file,\n]);\n```\n\n### Upload file with HTML Form\n\n```php\n\u003cform action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\"\u003e\n    Select file to upload:\n    \u003cinput type=\"file\" name=\"fileToUpload\" id=\"fileToUpload\"\u003e\n    \u003cinput type=\"submit\" value=\"Upload File\" name=\"submit\"\u003e\n\u003c/form\u003e\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Orhanerday\\OpenAi\\OpenAi;\n\nif ($_SERVER['REQUEST_METHOD'] == 'POST') {\n    ob_clean();\n    $open_ai = new OpenAi(env('OPEN_AI_API_KEY'));\n    $tmp_file = $_FILES['fileToUpload']['tmp_name'];\n    $file_name = basename($_FILES['fileToUpload']['name']);\n    $c_file = curl_file_create($tmp_file, $_FILES['fileToUpload']['type'], $file_name);\n\n    echo \"[\";\n    echo $open_ai-\u003euploadFile(\n        [\n            \"purpose\" =\u003e \"answers\",\n            \"file\" =\u003e $c_file,\n        ]\n    );\n    echo \",\";\n    echo $open_ai-\u003elistFiles();\n    echo \"]\";\n\n}\n\n```\n\n### Delete file\n\n ```php\n$result = $open_ai-\u003edeleteFile('file-xxxxxxxx');\n```\n\n### Retrieve file\n\n ```php\n$file = $open_ai-\u003eretrieveFile('file-xxxxxxxx');\n```\n\n### Retrieve file content\n\n ```php\n$file = $open_ai-\u003eretrieveFileContent('file-xxxxxxxx');\n```\n\n## Fine-tunes\n\nManage fine-tuning jobs to tailor a model to your specific training data.\n\n### Create fine-tune\n\n ```php\n$result = $open_ai-\u003ecreateFineTune([\n        \"model\" =\u003e \"gpt-3.5-turbo-1106\",\n        \"training_file\" =\u003e \"file-U3KoAAtGsjUKSPXwEUDdtw86\",\n]);\n```\n\n### List fine-tune\n\n ```php\n$fine_tunes = $open_ai-\u003elistFineTunes();\n```\n\n### Retrieve fine-tune\n\n ```php\n$fine_tune = $open_ai-\u003eretrieveFineTune('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n```\n\n### Cancel fine-tune\n\n ```php\n$result = $open_ai-\u003ecancelFineTune('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n```\n\n### List fine-tune events\n\n ```php\n$fine_tune_events = $open_ai-\u003elistFineTuneEvents('ft-AF1WoRqd3aJAHsqc9NY7iL8F');\n```\n\n### Delete fine-tune model\n\n ```php\n$result = $open_ai-\u003edeleteFineTune('curie:ft-acmeco-2021-03-03-21-44-20');\n```\n\n## Retrieve engine\n\n**_(Deprecated)_**\n\nRetrieves an engine instance, providing basic information about the engine such as the owner and availability.\n\n ```php\n$engine = $open_ai-\u003eengine('davinci');\n```\n\n## Models\n\nList and describe the various models available in the API.\n\n### List models\n\nLists the currently available models, and provides basic information about each one such as the owner and availability.\n\n ```php\n$result = $open_ai-\u003elistModels();\n```\n\n### Retrieve model\n\nRetrieves a model instance, providing basic information about the model such as the owner and permissioning.\n\n ```php\n$result = $open_ai-\u003eretrieveModel(\"text-ada-001\");\n```\n\n## Printing results *i.e.* `$search`\n\n ```php\necho $search;\n```\n## Assistants (beta)\n\nAllows you to build AI assistants within your own applications.\n\n### Create assistant\n\nCreate an assistant with a model and instructions.\n\n```php\n$data = [\n    'model' =\u003e 'gpt-3.5-turbo',\n    'name' =\u003e 'my assistant',\n    'description' =\u003e 'my assistant description',\n    'instructions' =\u003e 'you should cordially help me',\n    'tools' =\u003e [],\n    'file_ids' =\u003e [],\n];\n\n$assistant = $open_ai-\u003ecreateAssistant($data);\n```\n\n### Retrieve assistant\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n\n$assistant = $open_ai-\u003eretrieveAssistant($assistantId);\n```\n\n### Modify assistant\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n$data = [\n    'name' =\u003e 'my modified assistant',\n    'instructions' =\u003e 'you should cordially help me again',\n];\n\n$assistant = $open_ai-\u003emodifyAssistant($assistantId, $data);\n```\n\n### Delete assistant\n\n```php\n$assistantId = 'asst_DgiOnXK7nRfyvqoXWpFlwESc';\n\n$assistant = $open_ai-\u003edeleteAssistant($assistantId);\n```\n\n### Lists assistants\n\nReturns a list of assistants.\n\n```php\n$query = ['limit' =\u003e 10];\n\n$assistants = $open_ai-\u003elistAssistants($query);\n```\n\n### Create assistant file\n\nCreate an assistant file by attaching a File to an assistant.\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n$fileId = 'file-jrNZZZBAPGnhYUKma7CblGoR';\n\n$file = $open_ai-\u003ecreateAssistantFile($assistantId, $fileId);\n```\n\n### Retrieve assistant file\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n$fileId = 'file-jrNZZZBAPGnhYUKma7CblGoR';\n\n$file = $open_ai-\u003eretrieveAssistantFile($assistantId, $fileId);\n```\n\n### Delete assistant file\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n$fileId = 'file-jrNZZZBAPGnhYUKma7CblGoR';\n\n$file = $open_ai-\u003edeleteAssistantFile($assistantId, $fileId);\n```\n\n### List assistant files\n\nReturns a list of assistant files.\n\n```php\n$assistantId = 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz';\n$query = ['limit' =\u003e 10];\n\n$files = $open_ai-\u003elistAssistantFiles($assistantId, $query);\n```\n\n## Threads (beta)\n\nCreate threads that assistants can interact with.\n\n### Create thread\n\n```php\n$data = [\n    'messages' =\u003e [\n        [\n            'role' =\u003e 'user',\n            'content' =\u003e 'Hello, what is AI?',\n            'file_ids' =\u003e [],\n        ],\n    ],\n];\n\n$thread = $open_ai-\u003ecreateThread($data);\n```\n\n### Retrieve thread\n\n```php\n$threadId = 'thread_YKDArENVWFDO2Xz3POifFYlp';\n\n$thread = $open_ai-\u003eretrieveThread($threadId);\n```\n\n### Modify thread\n\n```php\n$threadId = 'thread_YKDArENVWFDO2Xz3POifFYlp';\n$data = [\n    'metadata' =\u003e ['test' =\u003e '1234abcd'],\n];\n\n$thread = $open_ai-\u003emodifyThread($threadId, $data);\n```\n\n### Delete thread\n\n```php\n$threadId = 'thread_YKDArENVWFDO2Xz3POifFYlp';\n\n$thread = $open_ai-\u003edeleteThread($threadId);\n```\n\n## Messages (beta)\n\nCreate messages within threads.\n\n### Create message\n\n```php\n$threadId = 'thread_YKDArENVWFDO2Xz3POifFYlp';\n$data = [\n    'role' =\u003e 'user',\n    'content' =\u003e 'How does AI work? Explain it in simple terms.',\n];\n\n$message = $open_ai-\u003ecreateThreadMessage($threadId, $data);\n```\n\n### Retrieve message\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$messageId = 'msg_d37P5XgREsm6BItOcppnBO1b';\n\n$message = $open_ai-\u003eretrieveThreadMessage($threadId, $messageId);\n```\n\n### Modify message\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$messageId = 'msg_d37P5XgREsm6BItOcppnBO1b';\n$data = [\n    'metadata' =\u003e ['test' =\u003e '1234abcd'],\n];\n\n$message = $open_ai-\u003emodifyThreadMessage($threadId, $messageId, $data);\n```\n\n### Lists messages\n\nReturns a list of messages for a given thread.\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$query = ['limit' =\u003e 10];\n\n$messages = $open_ai-\u003elistThreadMessages($threadId, $query);\n```\n\n### Retrieve message file\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$messageId = 'msg_CZ47kAGZugAfeHMX6bmJIukP';\n$fileId = 'file-CRLcY63DiHphWuBrmDWZVCgA';\n\n$file = $open_ai-\u003eretrieveMessageFile($threadId, $messageId, $fileId);\n```\n\n### List message files\n\nReturns a list of message files.\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$messageId = 'msg_CZ47kAGZugAfeHMX6bmJIukP';\n$query = ['limit' =\u003e 10];\n\n$files = $open_ai-\u003elistMessageFiles($threadId, $messageId, $query);\n```\n\n## Runs (beta)\n\nRepresents an execution run on a thread.\n\n### Create run\n\n```php\n$threadId = 'thread_d86alfR2rfF7rASyV4V7hicz';\n$data = ['assistant_id' =\u003e 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz'];\n\n$run = $open_ai-\u003ecreateRun($threadId, $data);\n```\n\n### Retrieve run\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n\n$run = $open_ai-\u003eretrieveRun($threadId, $runId);\n```\n\n### Modify run\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n$data = [\n    'metadata' =\u003e ['test' =\u003e 'abcd1234'],\n];\n\n$run = $open_ai-\u003emodifyRun($threadId, $runId, $data);\n```\n\n### Lists runs\n\nReturns a list of runs belonging to a thread.\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$query = ['limit' =\u003e 10];\n\n$runs = $open_ai-\u003elistRuns($threadId, $query);\n```\n\n### Submit tool outputs\n\nWhen a run has the status: \"requires_action\" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n$outputs = [\n    'tool_outputs' =\u003e [\n        ['tool_call_id' =\u003e 'call_abc123', 'output' =\u003e '28C'],\n    ],\n];\n\n$run = $open_ai-\u003esubmitToolOutputs($threadId, $runId, $outputs);\n```\n\n### Cancel run\n\nCancels a run that is \"in_progress\".\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n\n$run = $open_ai-\u003ecancelRun($threadId, $runId);\n```\n\n### Create thread and run\n\nCreate a thread and run it in one request.\n\n```php\n$data = [\n    'assistant_id' =\u003e 'asst_zT1LLZ8dWnuFCrMFzqxFOhzz',\n    'thread' =\u003e [\n        'messages' =\u003e [\n            [\n                'role' =\u003e 'user',\n                'content' =\u003e 'Hello, what is AI?',\n                'file_ids' =\u003e [],\n            ],\n        ],\n    ],\n];\n\n$run = $open_ai-\u003ecreateThreadAndRun($data);\n```\n\n### Retrieve run step\n\nRetrieves a step in execution of a run.\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n$stepId = 'step_kwLG0vPQjqVyQHVoL7GVK3aG';\n\n$step = $open_ai-\u003eretrieveRunStep($threadId, $runId, $stepId);\n```\n\n### List run steps\n\nReturns a list of run steps belonging to a run.\n\n```php\n$threadId = 'thread_JZbzCYpYgpNb79FNeneO3cGI';\n$runId = 'run_xBKYFcD2Jg3gnfrje6fhiyXj';\n$query = ['limit' =\u003e 10];\n\n$steps = $open_ai-\u003elistRunSteps($threadId, $runId, $query);\n```\n\n## Testing\n\nTo run all tests:\n\n```bash\ncomposer test\n```\n\nTo run only those tests that work for most user (exclude those that require a missing folder or that hit deprecated\nendpoints no longer available to most users):\n\n```bash\n./vendor/bin/pest --group=working\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease report security vulnerabilities to [orhanerday@gmail.com](mailto:orhanerday@gmail.com)\n\n## Credits\n\n- [Orhan Erday](https://github.com/orhanerday)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Donation\n\n\u003ca href=\"https://www.buymeacoffee.com/orhane\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=orhanerday/open-ai\u0026type=Date)](https://star-history.com/#orhanerday/open-ai\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhanerday%2Fopen-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forhanerday%2Fopen-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhanerday%2Fopen-ai/lists"}