A production-ready OpenAI-compatible API gateway whose upstream engine is
Val Town's native AI (std/openai → the ValTownOpenAI proxy, authenticated
by the ambient valtown token). No external API key required — Cline, Roo
Code, Cursor, the Python OpenAI SDK, or cURL can all connect to this gateway
and chat through real SSE streaming.
{origin}/api/provider/v1gpt-5.4-nano (Val Town native)PROVIDER_API_KEY)baseUrl = {origin}/api/provider/v1
apiKey = <the key shown in the UI>
modelId = gpt-5.4-nano
curl {origin}/api/provider/v1/chat/completions \ -H "Authorization: Bearer <KEY>" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-5.4-nano","stream":true, "messages":[{"role":"user","content":"مرحباً"}]}'
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /health | no | {status:"ok", service:"internal-bridge"} |
| GET | /api/provider/v1 | no | Service info & limits |
| GET | /api/provider/v1/models | no | Active model, OpenAI format |
| POST | /api/provider/v1/chat/completions | yes | Chat (SSE or non-streaming) |
| GET | /api/provider/config | no | {model, apiKey, keyRequired} for the UI |
main.ts (http) — router: mounts the gateway under /api/provider/v1,
serves the RTL frontend and assets.lib/bridge.ts (script) — the internal provider bridge: sanitizeMessages
(never throws), max_tokens clamping, auto-healing singleton that re-reads
platform credentials, and real SSE streaming via the OpenAI SDK.public/ — Arabic RTL UI (playground, connection info, integration
snippets, activity/usage).PROVIDER_API_KEY — the gateway bearer key (required on chat completions).PROVIDER_MODEL — optional, overrides the default gpt-5.4-nano.max_tokens is auto-clamped to the engine ceiling to avoid upstream errors.