A simple one-file PHP wrapper for the Grok API.
- Single-file PHP implementation for Grok AI
- Support for both text and image inputs
- Cloudflare AI Gateway integration
- Session-based chat history
- Mobile-friendly responsive design
- Image upload and preview functionality
- PHP 8.0 or higher
- cURL extension enabled
- Valid Grok API key
-
Clone this repository:
git clone https://github.com/yourusername/grok-php.git cd grok-php
-
Create a
.env
file with your API credentials:api-key=your-grok-api-key cf-account-id=your-cloudflare-account-id
-
Start the PHP dev server:
php -S localhost:8000
-
Open your browser and navigate to
http://localhost:8000
Get your Grok API key from here
Create a new AI Gateway on Cloudflare (for free) and get the account id from here
Fill in the API key as api-key
and the account id as cf-account-id
in render environment variables
Deploy the app
Open the app and start chatting!
This app can be deployed 0.1vCPU 0.1GB RAM instance for free on Render