Skip to main content

Chat API

Interact with the IslamChat Assistant through a conversational API.

HTTP Endpoint Summary

MethodEndpointDescription
POST/api/chatSend a message to the assistant

Authentication

To access this endpoint, you must include a API key in the request header.

x-api-key: YOUR_API_KEY

API keys are provided manually for now. Contact us at apps@midade.ai to request one.

Request

Request Body Parameters

FieldTypeDescription
textstringThe message content to send to the assistant.
thread_idstring | nullThe ID of the thread to continue. Use null to start a new thread.

Re-using the same thread_id will continue the same conversation context. Use null to reset context and start a fresh session.


Code Examples

fetch("https://ai.midadedev.com/api/chat", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": "msk-your-secret-key", // Required API key
},
body: JSON.stringify({
text: "السلام عليكم", // The user’s message
thread_id: null, // Start a new thread
}),
})
.then((res) => res.json())
.then((data) => console.log(data));

Response

Response Fields

FieldTypeDescription
thread_idstringThe ID of the conversation thread
messagestringThe assistant’s reply to the user’s message
titlestringA system-generated title summarizing the chat

Error Responses

Status CodeMeaningCause
401UnauthorizedMissing or invalid x-api-key
400Bad RequestInvalid or malformed JSON body
404Not FoundAssistant or endpoint does not exist
429Too Many RequestsYou’ve hit your rate limit
500Internal Server ErrorSomething went wrong on our end

Sample Output

Expect a sample response containing:

{
"thread_id": "thread_xxxxxxxxxxxxxxxxxxxxxxxx",
"message": "وعليكم السلام! كيف يمكنني مساعدتك اليوم؟",
"title": "Random Greeting Chaos!"
}

Rate Limits

Each API key has a rate limit of 100 requests per minute. Exceeding this will return a 429 Too Many Requests error.

API Version

This is the v1 of the API. Backward-incompatible changes will result in a new version.