API reference
The Ask AI API answers a question from your site's content and returns the answer with its sources. It has one endpoint, POST https://api.sorchy.com/v1/ask, called from your own server. A Postman collection is available under Tools > API > Documentation; put your key in its apiKey variable to try it.
Keys
Create keys under Tools > API > Setup, up to 5 per project, each named for where it is used. Send the key in the Authorization header. Keep it on your server, for example in an environment variable; never put it in browser code, a mobile app bundle or a public repository.
POST https://api.sorchy.com/v1/ask
Authorization: Bearer sk_live_...
Content-Type: application/json
Request
| Field | Type | Required | Description |
|---|---|---|---|
question | string | Yes | The question, up to 1,000 characters. The project's personal data masking applies. |
conversation_id | string | No | The conversation_id of an earlier answer, to continue that conversation with its earlier questions as context. |
lang | "tr" or "en" | No | The language of the user's page or app. Answers normally follow the question's language and the project's answer language setting. |
stream | boolean | No | true returns the answer in pieces as NDJSON. Default false. |
A minimal request body is {"question": "When do applications open?"}. Ready-made requests for cURL, JavaScript and Python are in the panel under Tools > API > Documentation.
Response
answer is Markdown. Marks such as [1] and [3] point to the sources with the same n; sources holds only the sources the answer cites.
{
"conversation_id": "5f0c…",
"message_id": "a94b…",
"answer": "… [1] … [3]",
"sources": [
{ "n": 1, "title": "…", "url": "https://…" },
{ "n": 3, "title": "…", "url": "https://…" }
]
}
Streaming
With "stream": true in the body, the answer comes as NDJSON, one JSON event per line. The sources event lists every page found, so you can link [n] marks while the text arrives; done lists only the cited sources. On an error, an error event arrives and the stream ends.
{"type": "conversation", "conversation_id": "5f0c…", "message_id": "a94b…"}
{"type": "sources", "sources": [{"n": 1, "title": "…", "url": "…"}]}
{"type": "token", "text": "…"}
{"type": "token", "text": "…"}
{"type": "done", "sources": [{"n": 1, "title": "…", "url": "…"}]}
Follow-up questions
Send the conversation_id of an answer with the next request, and the new question is read in the context of the earlier ones, so “And the fee?” works. API conversations appear under Conversations on the API channel.
Errors
Errors return an HTTP status and a body of the form {"error": {"code", "message"}}. Act on code; message may change.
| HTTP | Code | Meaning |
|---|---|---|
| 400 | question_required | The question is empty. |
| 401 | missing_api_key | No Authorization header, or not in the form Bearer sk_live_.... |
| 401 | invalid_api_key | The key is not valid or has been revoked. |
| 403 | api_not_in_package | The project's package does not include the API. |
| 403 | api_off | The API is turned off in Tools > API > Setup. |
| 403 | assistant_paused | The package's days or questions have run out; answers are paused. |
| 409 | index_empty | The project has no content to answer from yet. |
| 422 | invalid_request | The request body is not valid; details names the wrong field. |
| 429 | rate_limited | Too many questions for this key; wait the seconds in the Retry-After header. |
| 502 | answer_failed | The answer could not be made; try again shortly. |
Limits
Up to 60 questions per minute per key.
Each question counts toward the project's monthly questions, like questions on your site.
Server-to-server only: requests from browsers (CORS) are refused.
An answer can take from a few seconds to a minute; set your client timeout to at least 120 seconds.