DEVELOPER DOCUMENTATION

KleboAI Developer API

Integrate AI-powered image detection into your applications. Analyze images for AI-generated content using a simple REST API.

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 score

Authentication

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 TypeHeaderFormatLifetime
Access TokenAuthorizationBearer <token>Short-lived
Refresh TokenBody parameterStringLong-lived

API Reference

The following endpoints are available. All endpoints use the base URL configured in your environment.

MethodEndpointDescription
POST/auth/loginAuthenticate and receive tokens
POST/auth/registerCreate a new account
POST/auth/refresh-tokenRefresh an expired access token
POST/auth/verify-emailVerify email address
POST/scan/imageScan an image for AI content
GET/api-keysList your API keys
POST/api-keys/regenerateGenerate or regenerate an API key
GET/wallet/summaryGet credit balance and usage summary
GET/wallet/transactionsList credit transaction history
POST/contact-usSubmit a contact/support request
GET/v1/packagesList 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.

DetailValue
MethodPOST
Endpoint/scan/image
Content-Typemultipart/form-data
Field nameimage
Accepted formatsJPG, PNG, WEBP
AuthenticationRequired (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 result

Error Codes

The API uses standard HTTP status codes. Responses include a message field describing the error.

StatusCodeDescription
200OKRequest succeeded
400Bad RequestMissing or invalid parameters
401UnauthorizedInvalid or expired access token
403ForbiddenInsufficient permissions or role
404Not FoundResource does not exist
409ConflictResource already exists or state conflict
422UnprocessableValidation failed on one or more fields
429Too Many RequestsRate limit exceeded
500Server ErrorAn 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.

EndpointMethodDescription
/wallet/summaryGETTotal credits, spent, available, last package
/wallet/transactionsGETPaginated credit transaction history
/v1/packagesGETAvailable 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.

ActionEndpointMethod
List API keys/api-keysGET
Generate / Regenerate key/api-keys/regeneratePOST

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.

Contact Us