Web UI for OpenAI GPT stream chat API
Top 69.8% on sourcepulse
This project provides a pure PHP implementation for interacting with OpenAI's GPT chat API, featuring real-time streaming of responses and a simple web UI. It's designed for developers and users who want a straightforward, framework-agnostic way to integrate GPT capabilities into their applications, offering a functional demo out-of-the-box.
How It Works
The backend uses PHP's cURL library with CURLOPT_WRITEFUNCTION
to handle streaming responses from OpenAI. A custom StreamHandler
class processes incoming data chunks, buffering incomplete JSON payloads and parsing them into meaningful content. The frontend utilizes JavaScript's EventSource
API to receive these streamed updates, displaying them with a typing effect and syntax highlighting for code blocks.
Quick Start & Requirements
'YOUR_OPENAI_API_KEY'
in chat.php
with your actual API key.index.html
via your web server.Highlighted Details
Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
OpenAI's rate limiting on free accounts can significantly impact response times. Enabling sensitive word detection may introduce latency due to per-sentence processing. The project relies on native PHP cURL and frontend JavaScript, with no external backend dependencies beyond the API key.
2 years ago
1 day