Multi-provider OpenAI-compatible REST API in pure PHP (built-in web server + cURL)
Base URL: http://localhost:3000A pure-PHP OpenAI-compatible API gateway with zero dependencies. Serves the chat UI from public/ and exposes a standard /v1 API.
| Model ID | Display name | Provider |
|---|---|---|
aibangla | Bangla AI | AIBanglaChat |
muslimgpt | MuslimGPT | MuslimGPT |
myquran | MyQuran AI | MyQuran |
aichatting | AIChatting | AIChatting.net |
Requirements: PHP 8+ with the cURL and OpenSSL extensions enabled.
# 1. Copy the example config
cp .env.example .env
# 2. Boot the built-in PHP web server
php -S localhost:3000 index.php
Open http://localhost:3000 for the chat UI, or http://localhost:3000/docs.html for this page.
Optional, controlled by API_KEY in .env.
# If API_KEY is set, include this header:
Authorization: Bearer your_secret_api_key
Lists all available model IDs.
{ "object": "list", "data": [{ "id": "aibangla", "object": "model", "created": 1788935057, "owned_by": "aibangla" }] }
Generate completions using the selected model.
| Field | Type | Required | Description |
|---|---|---|---|
model | string | optional | Model ID: aibangla, muslimgpt, myquran, aichatting. |
messages | array | yes | {role, content} array. |
stream | boolean | optional | true for SSE streaming. |
curl -X POST http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "muslimgpt",
"messages": [{ "role": "user", "content": "Hello!" }],
"stream": false
}'
Set stream: true to receive Server-Sent Events ending with [DONE].
data: {"id":"chatcmpl-x","object":"chat.completion.chunk","created":1788,"model":"muslimgpt","choices":[{"index":0,"delta":{"content":"Peace "},"finish_reason":null}]}
data: {"id":"chatcmpl-x","object":"chat.completion.chunk","created":1788,"model":"muslimgpt","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Configuration for opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"local-ai": {
"api": "openai",
"name": "Local AI Gateway",
"options": {
"apiKey": "dummy",
"baseURL": "http://localhost:3000/v1"
},
"models": {
"aibangla": { "id": "aibangla", "name": "Bangla AI", "tool_call": false, "reasoning": false },
"muslimgpt": { "id": "muslimgpt", "name": "MuslimGPT", "tool_call": false, "reasoning": false },
"myquran": { "id": "myquran", "name": "MyQuran AI", "tool_call": false, "reasoning": false },
"aichatting": { "id": "aichatting", "name": "AIChatting", "tool_call": false, "reasoning": false }
}
}
},
"model": "local-ai/aibangla"
}
{ "error": { "message": "Description of error" } }