Please use our our swagger documentation https://app.kolas.ai/api/documentation. For testing API use credentials (client ID and client secret) generated in your account settings https://app.kolas.ai/pages/account-setting
For generating your API clients you can use our
Here’s a step-by-step guide to using the Kolas.Ai API:
To use the API, you need to authenticate via OAuth2 and obtain an access token.
Register for an account.
Obtain the Client ID and Client Secret for your application.
Use these credentials to request a token by sending a POST request to the token endpoint:
Request:
POST /oauth/token
Content-Type: application/x-www-form-urlencoded
Request Body:
grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET
In the response, you’ll receive an access_token that you’ll use to authenticate API requests.
Once you have your access token, you can make a request to predict the category of your messages.
Send a POST request to the /predictions/predict
endpoint:
Request:
POST /predictions/predict
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Request Body should include two required parameters:
projectId
: The ID of the project configured for predictions.messages
: An array of messages for which you want to make a prediction.Example request body:
{
"projectId": 3457,
"messages": [
{
"message": "What did you do yesterday?"
},
{
"message": "Hello world!"
}
]
}
Name | Type | Description |
projectId | integer | ID of project |
messages | array | list of messages for classification |
messages.message | string | message for classification |
Response will include the prediction for each message:
{
"predictions": [
{
"categories": [
"Neutral",
"Insult",
"Spam"
],
"prediction": "Neutral",
"probability": "0.99808084964752",
"message": "What did you do yesterday?"
},
{
"categories": [
"Neutral",
"Insult",
"Spam"
],
"prediction": "Neutral",
"probability": "0.8446232676506",
"message": "Hello world!"
}
]
}
Name | Type | Description |
predictions | array | list of predictions |
predictions.categories | array | list of supported categories |
predictions.prediction | string | predicted category |
predictions.probability | string | probability of prdiction (max value 1) |
predictions.message | string | processed message |
If your request fails, you’ll receive an error. The API provides several error codes:
401 Unauthorized: If the access token is missing or invalid. Example response:
{
"message": "Unauthenticated."
}
422 Validation Error: If there’s a validation issue with the request (e.g., missing required fields). Example response:j
{
"errors": ["Missing projectId field."],
"message": "Validation exception"
}
5XX Server Error: If an unexpected error occurs on the server. Example response:
{
"message": "Internal server error. Contact technical support."
}
If you encounter any questions or issues, feel free to ask!