# PHP 7.4 Chat Widget (OpenAI Responses API + MySQL)

A minimal chat widget you can drop onto any PHP 7.4 + Apache server. Messages are stored in MySQL.
Uses OpenAI **Responses API**.

## Quick Start

1) **Create DB & tables**
```sql
-- import db.sql
```

2) **Copy & edit env**
```bash
cp .env.sample .env
# fill in OPENAI_API_KEY and DB credentials
```

3) **Apache**
Make sure DocumentRoot points to `/public` or place contents of `/public` under your web root.

4) **Permissions**
Ensure PHP can read `.env` and the `public/` files.

5) **Open the widget page**
Visit `http://your-host/index.php`

## Notes
- Default model is `gpt-4o-mini`. Change via `.env` (OPENAI_MODEL).
- Endpoint defaults to `https://api.openai.com/v1` (Responses API at `/responses`).
- If you prefer Chat Completions, set `USE_CHAT_COMPLETIONS=1` in `.env` (optional) and the code will fall back.