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
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
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
}
}
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..."
}]
}
Create and manage chatbots programmatically.
GET /v1/chatbots
POST /v1/chatbots
PUT /v1/chatbots/:id
DELETE /v1/chatbots/:id
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.
Request successful
Invalid request parameters
Missing or invalid API key
Rate limit exceeded
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