Ghaito API
Approved apps call the same Ghaito engine used in chat: answers, math, file-style conversion commands, and image generation. Pick a language with lang. Each key allows 30 requests a minute. Past that, the API says the AI agent is busy.
Get a key
- Create a Ghaito account and open API access.
- Request a key and describe the app.
- After an admin approves it, open the page again and copy the secret once.
Keys look like gh_ followed by 48 hex characters. Store the secret on your server. Do not put it in a public web page.
Endpoint
POST /ai/api/v1/chat.php
Send Authorization: Bearer <key> and Content-Type: application/json. Cross-origin browser calls are allowed for those two headers. Cookies are not used.
Request
{
"message": "Explain photosynthesis in two sentences",
"mode": "balanced",
"lang": "en"
}
messageis required, up to 4000 characters.modeisbalanced,precise, orcreative.langis one ofen,ne,hi,es,fr,zh,ar,ja. An unknown code falls back to English.
Image example: Draw a quiet lake in the Himalaya at sunrise. Conversion-style prompts apply when the same account has just uploaded a file in the chat. The API itself accepts text.
Response
{
"id": "r_…",
"reply": "Photosynthesis is how plants turn light into food…",
"lang": "en",
"model": "ghaito-local"
}
model is the admin-enabled provider model, or ghaito-local when no provider key is turned on. Lines that start with Image: or Download: are meant to be shown as media or links.
Example
curl -s https://your-host/ai/api/v1/chat.php \
-H "Authorization: Bearer gh_your_key" \
-H "Content-Type: application/json" \
-d '{"message":"128 * 24","lang":"en"}'
Errors
| HTTP | error | Meaning |
|---|---|---|
| 401 | invalid_key | Missing or unknown bearer token. |
| 403 | pending | The admin has not approved this key. |
| 403 | declined | The admin declined this key. |
| 400 | missing_message | The message field is empty. |
| 400 | too_long | The message is over 4000 characters. |
| 429 | rate_limited | The key or the IP is over its limit. message is “The AI agent is busy. Please try again in a moment.” |
| 502 | upstream | The chat engine did not return a reply. |
Limits
Each approved key allows 30 requests per minute, and each IP allows 40. A public meta endpoint lists languages and those limits. Replies stay on this Ghaito server. If an admin has enabled a provider, that provider receives the conversation text needed to answer.