ChatGPT-Example
ChatGPT-Example copied to clipboard
Example of a ChatGPT on PHP and JS: GPT-3, GPT-3.5 and GPT-4 (chat.openai.com)
ChatGPT PHP Example
A simple example of using the GPT-3 API, GPT-3.5-turbo API, and the unofficial API from chat.openai.com (GPT-3.5 and GPT-4).
This example displays a chat in the browser where you can choose a GPT model. If you selected "chat.openai.com", you can specify a chatID, and support for communicating with the AI in dialogue mode will also be available.

Usage
To use the official API (GPT-3 and GPT-3.5-turbo), add OPENAI_API_KEY in the openai_chat_api.php file.
Additionally, to use the unofficial API from the chat.openai.com/chat page (GPT-3.5 and GPT-4), add ACCESS_TOKEN and COOKIE_PUID (only available for ChatGPT Plus users).
ACCESS_TOKEN:
Go to the page https://chat.openai.com/api/auth/session and copy the accessToken

COOKIE_PUID:
Go to the page https://chat.openai.com/chat, open the DevTools in your browser (F12) and copy the cookie _puid=user-...
