GhGhaitoAPI docs

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

  1. Create a Ghaito account and open API access.
  2. Request a key and describe the app.
  3. 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"
}

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

HTTPerrorMeaning
401invalid_keyMissing or unknown bearer token.
403pendingThe admin has not approved this key.
403declinedThe admin declined this key.
400missing_messageThe message field is empty.
400too_longThe message is over 4000 characters.
429rate_limitedThe key or the IP is over its limit. message is “The AI agent is busy. Please try again in a moment.”
502upstreamThe 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.