L0NG API Reference
The L0NG API allows you to integrate L0NG's conversational AI, image analysis, and training capabilities into your own applications. The API is RESTful and uses JSON for requests and responses.
Introduction
Base URL: https://chat.monyephoyn.workers.dev
All endpoints return JSON and accept JSON request bodies. CORS is enabled for all origins.
Authentication
Currently, the API does not require authentication for basic usage. However, to access admin endpoints, you must include an X-Owner-Email header with the owner's email address.
Rate Limits
Free tier: 20 messages per session. Signed‑in users (via Google) get 50 messages per session. IP‑based rate limiting may apply for excessive requests.
Chat Completion
POST /chat
Send a message to L0NG and receive an AI‑generated response.
Request Body
| Field | Type | Description |
|---|---|---|
message | string | Required. The user's message. |
sessionId | string | Unique session identifier. Default: "default". |
userId | string | User identifier for tracking. |
modelMode | string | "instant", "expert", or "apex". Default: "expert". |
raw | boolean | If true, returns raw L0NG response without Groq assistance. |
imageBase64 | string | Base64‑encoded image for vision analysis. |
temperature | number | Creativity (0.0–1.0). Default: 0.7. |
maxTokens | number | Maximum response length. Default: 80. |
Response
| Field | Type | Description |
|---|---|---|
response | string | The AI's reply. |
thought | string | L0NG's internal thinking (if available). |
vocabSize | number | Current vocabulary size of the local model. |
usedGroq | boolean | Whether Groq was used for this response. |
Example
curl -X POST https://chat.monyephoyn.workers.dev/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Hello, who are you?",
"modelMode": "expert"
}'
import requests
response = requests.post(
"https://chat.monyephoyn.workers.dev/chat",
json={"message": "Hello, who are you?", "modelMode": "expert"}
)
print(response.json()["response"])
fetch("https://chat.monyephoyn.workers.dev/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: "Hello, who are you?", modelMode: "expert" })
})
.then(r => r.json())
.then(data => console.log(data.response));
Train Model
POST /train
Train L0NG's local n‑gram model on custom text.
| Field | Type | Description |
|---|---|---|
text | string | Text to train on. |
curl -X POST https://chat.monyephoyn.workers.dev/train \
-H "Content-Type: application/json" \
-d '{"text": "The quick brown fox jumps over the lazy dog."}'
Upload Image
POST /upload
Upload an image for vision analysis. Returns a URL and base64 data.
Content-Type: multipart/form-data
| Field | Type | Description |
|---|---|---|
file | file | Image file (PNG, JPG, etc.) max 5MB. |
curl -X POST https://chat.monyephoyn.workers.dev/upload \
-F "file=@cat.jpg"
Health Check
GET /health
Returns the current status and vocabulary size.
curl https://chat.monyephoyn.workers.dev/health