When deployed: https://chatforge.<your-subdomain>.workers.dev
Locally: http://localhost:8787
Send a chat message and receive a streaming AI response.
Request Body:
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
]
}messages: Array of chat messages (max 100; each message max 32,000 chars)- Each message has
role("system","user", or"assistant") andcontent(string) - If no system message is provided, a default one is injected automatically
Response:
Content-Type: text/event-stream; charset=utf-8- SSE (Server-Sent Events) stream with
data:lines - Supports both Workers AI format (
{"response": "..."}) and OpenAI-compatible format ({"choices": [{"delta": {"content": "..."}}]}) - Stream ends with
data: [DONE]
Error Responses:
400 Bad Request— Malformed JSON body or invalidmessagesshape/size405 Method Not Allowed— GET requests to/api/chat404 Not Found— Unknown API routes500 Internal Server Error— AI service failures
Serves static frontend assets from the public/ directory.
All responses include:
X-Content-Type-Options: nosniffX-Frame-Options: DENYStrict-Transport-Security: max-age=31536000; includeSubDomainsReferrer-Policy: strict-origin-when-cross-originPermissions-Policy: camera=(), microphone=(), geolocation=()