API Reference

Complete API documentation for integrating CleverAI features into your applications

Overview

The CleverAI API provides programmatic access to all our AI features including chat, image generation, search, and chatbot management. Build powerful AI-driven applications with our RESTful API.

RESTful API

Standard HTTP methods

JSON Format

Request and response

Secure

API key authentication

Authentication

API Key Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header of each request.

curl -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ https://api.cleverai.app/v1/chat/completions

Keep your API keys secure and never expose them in client-side code.

API Endpoints

Chat Completions
POST

Generate chat completions using various AI models.

POST /v1/chat/completions

Request Body

{ "model": "gpt-4o", "messages": [ { "role": "user", "content": "Hello, how are you?" } ], "temperature": 0.7, "max_tokens": 500 }

Response

{ "id": "chat-abc123", "object": "chat.completion", "created": 1234567890, "model": "gpt-4o", "choices": [{ "message": { "role": "assistant", "content": "I'm doing well, thank you!" }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 10, "completion_tokens": 8, "total_tokens": 18 } }
Image Generation
POST

Generate images from text prompts.

POST /v1/images/generate

Request Body

{ "model": "dall-e-3", "prompt": "A serene mountain landscape at sunset", "size": "1024x1024", "quality": "hd", "n": 1 }

Response

{ "created": 1234567890, "data": [{ "url": "https://cdn.cleverai.app/images/abc123.png", "revised_prompt": "A serene mountain landscape..." }] }
Chatbot Management
GET/POST/PUT/DELETE

Create and manage chatbots programmatically.

GET /v1/chatbots
List all chatbots
POST /v1/chatbots
Create chatbot
PUT /v1/chatbots/:id
Update chatbot
DELETE /v1/chatbots/:id
Delete chatbot
Web Search
POST

Search the web with AI-enhanced results.

POST /v1/search
{ "query": "latest AI developments 2024", "num_results": 10, "include_images": true, "ai_summary": true }

Rate Limits

API rate limits vary by plan and endpoint. Rate limit information is included in response headers.

Free Plan

  • • 100 requests/hour
  • • 1,000 requests/day

Pro Plan

  • • 1,000 requests/hour
  • • 10,000 requests/day

Enterprise

  • • Custom limits
  • • Dedicated support

Response Headers

X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 999 X-RateLimit-Reset: 1234567890

Error Handling

The API uses standard HTTP status codes and returns detailed error messages.

200 OK
Success

Request successful

400 Bad Request
Client Error

Invalid request parameters

401 Unauthorized
Auth Error

Missing or invalid API key

429 Too Many Requests
Rate Limit

Rate limit exceeded

500 Internal Server Error
Server Error

Server-side error

SDKs & Libraries

Official SDKs for popular programming languages.

JavaScript/TypeScript

npm install @cleverai/sdk

Python

pip install cleverai

Ruby

gem install cleverai

Go

go get github.com/cleverai/go-sdk
Start Building

Get your API key and start integrating CleverAI into your applications.