Docs / Reference
API reference
The plain-text HTTP API the ask command uses. Everything works with curl.
Conventions
- Bodies and responses are plain text. No JSON tooling is needed on the client.
- Authenticated calls send the token in an
x-keyheader. - Any response beginning with
[ask-error]is an error. The HTTP status carries the class of error (400, 401, 403, 413, 429, 502).
POST /api/login
Body: username, newline, PIN. Returns a token as plain text.
printf 'rahul\nab12\n' | curl -s https://your-domain/api/login --data-binary @-POST /api/chat
Body: the question, or a transcript using <<<USER>>> and <<<ASSISTANT>>> markers. The reply streams back as plain text.
curl -N https://your-domain/api/chat -H "x-key: $TOKEN" -d "reverse a string in python"POST /api/pin
Body: current PIN, newline, new PIN. Returns a fresh token and signs out the other devices.
GET /api/me
Returns your username, usage for 24 hours, 7 days and all time, and your limits.
curl -s https://your-domain/api/me -H "x-key: $TOKEN"POST /api/admin
Used by the console. Send the administrator password in an x-admin header and JSON with an action: list, create, update, setActive, resetPin or delete.