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

FieldTypeDescription
messagestringRequired. The user's message.
sessionIdstringUnique session identifier. Default: "default".
userIdstringUser identifier for tracking.
modelModestring"instant", "expert", or "apex". Default: "expert".
rawbooleanIf true, returns raw L0NG response without Groq assistance.
imageBase64stringBase64‑encoded image for vision analysis.
temperaturenumberCreativity (0.0–1.0). Default: 0.7.
maxTokensnumberMaximum response length. Default: 80.

Response

FieldTypeDescription
responsestringThe AI's reply.
thoughtstringL0NG's internal thinking (if available).
vocabSizenumberCurrent vocabulary size of the local model.
usedGroqbooleanWhether 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.

FieldTypeDescription
textstringText 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

FieldTypeDescription
filefileImage 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