[LIVE] [VolkanSah/GPT-API-Integration-in-HTML-CSS-with-JS-PHP] 1 endpoint(s)
ChatGPT
API Proxy/ChatGPT
2,145 characters
Status: [LIVE]
Endpoints found:
https://openrouter.ai/api/v1
Source: https://github.com/VolkanSah/GPT-API-Integration-in-HTML-CSS-with-JS-PHP
# GPTChat
A minimal, dependency-free chat widget (PHP + vanilla JS) that works with **any OpenAI-compatible API**: OpenAI, OpenRouter, Ollama, LM Studio, llama.cpp, vLLM, and others.
## Features
- Streaming responses (Server-Sent Events), with a Stop button
- Conversation history (sent with every request)
- Provider-neutral: just change the base URL, key and model
- Optional moderation via the provider's `/moderations` endpoint
- Per-IP rate limiting, input limits, same-origin CORS by default
- API key stays on the server; the system prompt cannot be overridden by clients
- XSS-safe rendering (`textContent`), dark mode, mobile friendly
- No Composer, no npm, no build step
## Requirements
- PHP 7.4+ with the `curl` and `mbstring` extensions
## Quick start
```bash
git clone <this repo>
cd <this repo>
# Option A: environment variables
export API_BASE_URL=http://localhost:11434/v1 # e.g. Ollama
export MODEL=llama3.1
php -S localhost:8000
# Option B: config file
cp config.example.php config.php # then edit config.php
php -S localhost:8000
```
Open http://localhost:8000.
## Configuration
Every option can be set in `config.php` or via environment variable.
| Environment variable | Default | Description |
| --- | --- | --- |
| `API_BASE_URL` | `https://api.openai.com/v1` | Base URL of the OpenAI-compatible API |
| `API_KEY` (or `OPENAI_API_KEY`) | empty | API key; leave empty for local servers |
| `MODEL` | `gpt-4o-mini` | Model name |
| `SYSTEM_PROMPT` | `You are a helpful assistant.` | Server-side system prompt |
| `TEMPERATURE` | `0.7` | Sampling temperature |
| `MAX_TOKENS` | `1000` | Max tokens per response |
| `MAX_TOKENS_PARAM` | `max_tokens` | Set to `max_completion_tokens` for newer OpenAI models |
| `MAX_MESSAGES` | `40` | Max messages per request |
| `MAX_MESSAGE_CHARS` | `4000` | Max characters per message |
| `RATE_LIMIT_PER_MINUTE` | `20` | Requests per IP per minute (`0` = off) |
| `ALLOWED_ORIGINS` | empty | Comma-separated origins allowed f