API Overview
The KleboAI API enables programmatic access to our AI image detection engine. Submit any image and receive a confidence score indicating whether the content is AI-generated or authentic.
The API is REST-based, returns JSON responses, and authenticates via Bearer tokens. It supports image upload via multipart form data.
Quick Start
Get started in four steps — generate an API key, authenticate, send an image, and receive a detection result.
1. Create an account at kleboai.com
2. Generate an API key from your Dashboard
3. Authenticate with your Bearer token
4. Send an image to the scan endpoint
5. Receive AI-generation confidence scoreAuthentication
All API requests require a Bearer token in the Authorization header. Obtain your token via the /auth/login endpoint or by generating an API key in your Dashboard.
Header
Authorization: Bearer <your-access-token>Tokens expire after a set period. Use the /auth/refresh-token endpoint with a valid refresh token to obtain a new access token. If both tokens expire, you must authenticate again.
| Token Type | Header | Format | Lifetime |
|---|---|---|---|
| Access Token | Authorization | Bearer <token> | Short-lived |
| Refresh Token | Body parameter | String | Long-lived |
API Reference
The following endpoints are available. All endpoints use the base URL configured in your environment.
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/login | Authenticate and receive tokens |
| POST | /auth/register | Create a new account |
| POST | /auth/refresh-token | Refresh an expired access token |
| POST | /auth/verify-email | Verify email address |
| POST | /scan/image | Scan an image for AI content |
| GET | /api-keys | List your API keys |
| POST | /api-keys/regenerate | Generate or regenerate an API key |
| GET | /wallet/summary | Get credit balance and usage summary |
| GET | /wallet/transactions | List credit transaction history |
| POST | /contact-us | Submit a contact/support request |
| GET | /v1/packages | List available credit packages |
Note: Exact backend endpoints may vary. The above are documented from the frontend integration code and may be updated as the API evolves.
Scan Image Documentation
The core endpoint analyzes an uploaded image and determines the likelihood it was generated by AI.
| Detail | Value |
|---|---|
| Method | POST |
| Endpoint | /scan/image |
| Content-Type | multipart/form-data |
| Field name | image |
| Accepted formats | JPG, PNG, WEBP |
| Authentication | Required (Bearer token) |
Send the image as a FormData field named image. The response includes the detection verdict, confidence score, and remaining credits.
Request / Response Examples
A typical scan request sends a single image file. The response wraps the result in a standard success envelope.
Request (multipart/form-data)
POST /scan/image
Content-Type: multipart/form-data
Authorization: Bearer <token>
--boundary
Content-Disposition: form-data; name="image"; filename="photo.jpg"
Content-Type: image/jpeg
<binary image data>
--boundary--Response (200 OK)
{
"success": true,
"statusCode": 200,
"message": "Image scanned successfully.",
"data": {
"status": "completed",
"type": "image",
"aiGenerated": true,
"confidence": 0.87,
"creditsRemaining": 42,
"providerResponse": {
"status": "success",
"request": {
"id": "req_abc123",
"timestamp": 1693000000000,
"operations": 1
},
"type": {
"ai_generated": 87
},
"media": {
"id": "media_xyz789",
"uri": "https://..."
}
}
}
}Response — error
{
"success": false,
"statusCode": 401,
"message": "Unauthorized"
}cURL Example
curl -X POST https://example.com/scan/image \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "image=@/path/to/image.jpg"Replace YOUR_ACCESS_TOKEN with the token from your authentication flow and /path/to/image.jpg with the local path to your image file.
JavaScript Example
Use the native fetch API with FormData to upload and scan an image.
JavaScript (fetch)
async function scanImage(file) {
const formData = new FormData();
formData.append("image", file);
const response = await fetch("https://example.com/scan/image", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
},
body: formData,
});
const result = await response.json();
console.log("AI Generated:", result.data.aiGenerated);
console.log("Confidence:", result.data.confidence);
console.log("Credits left:", result.data.creditsRemaining);
return result;
}Python Example
Use the requests library to upload and scan an image via the API.
Python
import requests
def scan_image(file_path, token):
url = "https://example.com/scan/image"
headers = {"Authorization": f"Bearer {token}"}
with open(file_path, "rb") as f:
files = {"image": f}
response = requests.post(url, headers=headers, files=files)
result = response.json()
print(f"AI Generated: {result['data']['aiGenerated']}")
print(f"Confidence: {result['data']['confidence']}")
print(f"Credits left: {result['data']['creditsRemaining']}")
return resultError Codes
The API uses standard HTTP status codes. Responses include a message field describing the error.
| Status | Code | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 400 | Bad Request | Missing or invalid parameters |
| 401 | Unauthorized | Invalid or expired access token |
| 403 | Forbidden | Insufficient permissions or role |
| 404 | Not Found | Resource does not exist |
| 409 | Conflict | Resource already exists or state conflict |
| 422 | Unprocessable | Validation failed on one or more fields |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Server Error | An unexpected internal error occurred |
Error codes are based on the frontend error handling patterns and standard REST conventions. Exact backend codes may differ.
Credits Documentation
KleboAI uses a credit-based system. Each image scan deducts one credit from your balance. Credits are purchased via packages available in your Dashboard.
Your remaining credits are returned with each scan response in the creditsRemaining field. You can view your credit balance and transaction history via the /wallet/summary and /wallet/transactions endpoints.
| Endpoint | Method | Description |
|---|---|---|
| /wallet/summary | GET | Total credits, spent, available, last package |
| /wallet/transactions | GET | Paginated credit transaction history |
| /v1/packages | GET | Available credit packages and pricing |
Rate-Limit Documentation
Rate limits protect the API from abuse and ensure fair usage. When exceeded, the API returns a 429 Too Many Requests status.
Implement exponential backoff in your client to handle rate limits gracefully. The Retry-After header (if present) indicates how many seconds to wait before retrying.
Rate limit response
{
"success": false,
"statusCode": 429,
"message": "Too many requests. Please try again later."
}Exact rate limits are determined by your plan and account tier. Contact support for enterprise limit details.
API Key Management
API keys allow your applications to authenticate with the KleboAI API. View, generate, and manage keys from your Dashboard.
| Action | Endpoint | Method |
|---|---|---|
| List API keys | /api-keys | GET |
| Generate / Regenerate key | /api-keys/regenerate | POST |
The /api-keys endpoint returns your current API key along with createdAt and lastUsedAt timestamps. Use the regenerate endpoint to create a new key (the old key is invalidated).
Response
{
"success": true,
"data": {
"apiKey": "kb_live_abc123def456...",
"createdAt": "2024-01-15T10:30:00Z",
"lastUsedAt": "2024-08-20T14:22:00Z"
}
}Contact & Integration Support
For API integration questions, enterprise partnerships, or technical support, reach out through the contact form or email.