Welcome to Broke AI API
Broke AI API provides advanced AI-powered chat completions with integrated web search capabilities. Our API delivers intelligent responses enhanced with real-time information from the internet.
AI Chat
Get intelligent responses powered by Broke o2's advanced AI models with context awareness and customizable parameters.
Web Search
Integrated web search capabilities that provide real-time information and latest updates from across the internet.
Easy Integration
Simple RESTful API with comprehensive documentation and interactive playground for testing.
Getting Started
To use the Broke AI API, you need an API key. Get your API key from the dashboard:
- Visit the Dashboard
- Sign up or log in to your account
- Get your API key from the dashboard
- Use the API key in your requests
Rate Limits
The API has the following rate limits:
- Free users: 200 requests per day
- Premium users: Unlimited requests
- Rate limiting: 3 requests per second per IP
Base URL
All API requests should be made to: https://broke-o2-api.vercel.app/api
Authentication
All API requests require an API key. Include your API key in the request header:
X-API-Key: YOUR_API_KEY_HERE
Or use the Authorization header with Bearer token:
Authorization: Bearer YOUR_API_KEY_HERE
API Endpoints
POST /api/ai/chat
Get AI response for user message with optional web search integration.
Request Body
{
"message": "string (required)",
"sessionId": "string (optional)",
"webSearch": "boolean (optional, default: true)",
"temperature": "number (optional, 0-2, default: 0.7)",
"maxTokens": "integer (optional, 1-4096, default: 2048)"
}
Response
{
"success": true,
"data": {
"response": "string",
"metadata": {
"usedWebSearch": "boolean",
"model": "string",
"timestamp": "string"
}
}
}
POST /api/search
Perform web search with customizable parameters.
Request Body
{
"query": "string (required)",
"region": "string (optional)",
"depth": "integer (optional, 1-20, default: 5)",
"timeFilter": "string (optional: day|week|month|year)"
}
Response
{
"success": true,
"data": {
"results": [
{
"title": "string",
"url": "string",
"description": "string"
}
],
"count": "integer",
"timestamp": "string"
}
}
GET /api/system/info
Get system information and performance metrics.
Query Parameters
detail - Level of detail: basic|full|lightweight
Response
{
"success": true,
"data": {
"basic": {
"os": "string",
"nodeVersion": "string",
"uptime": "string"
},
"performance": {
"classification": "string",
"cpuCores": "integer",
"memoryGB": "number"
}
}
}
POST /api/sessions
Create a new chat session for context-aware conversations.
Request Body
{
"title": "string (optional)",
"webSearch": "boolean (optional, default: true)",
"temperature": "number (optional, 0-2, default: 0.7)"
}
Response
{
"success": true,
"data": {
"id": "string (UUID)",
"title": "string",
"createdAt": "string (ISO timestamp)",
"webSearch": "boolean",
"temperature": "number"
}
}
Integration Examples
JavaScript (Browser)
async function chatWithAI(message, apiKey) {
const response = await fetch('https://broke-o2-api.vercel.app/api/ai/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify({
message: message,
webSearch: true,
temperature: 0.7
})
});
const data = await response.json();
return data;
}
// Usage
chatWithAI('Hello, what is AI?', 'YOUR_API_KEY_HERE')
.then(result => console.log(result.data.response));
JavaScript (Node.js)
const axios = require('axios');
async function chatWithAI(message, apiKey) {
try {
const response = await axios.post(
'https://broke-o2-api.vercel.app/api/ai/chat',
{
message: message,
webSearch: true,
temperature: 0.7
},
{
headers: {
'X-API-Key': apiKey
}
}
);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
}
// Usage
chatWithAI('Hello, what is AI?', 'YOUR_API_KEY_HERE')
.then(result => console.log(result.data.response));
Python
import requests
def chat_with_ai(message, api_key):
url = 'https://broke-o2-api.vercel.app/api/ai/chat'
headers = {
'Content-Type': 'application/json',
'X-API-Key': api_key
}
data = {
'message': message,
'webSearch': True,
'temperature': 0.7
}
response = requests.post(url, json=data, headers=headers)
return response.json()
# Usage
result = chat_with_ai('Hello, what is AI?', 'YOUR_API_KEY_HERE')
print(result['data']['response'])
cURL
curl -X POST https://broke-o2-api.vercel.app/api/ai/chat \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"message": "Hello, what is AI?",
"webSearch": true,
"temperature": 0.7
}'
React Component
import React, { useState } from 'react';
function ChatComponent() {
const [message, setMessage] = useState('');
const [response, setResponse] = useState('');
const [apiKey, setApiKey] = useState('');
const sendMessage = async () => {
const res = await fetch('https://broke-o2-api.vercel.app/api/ai/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify({
message: message,
webSearch: true
})
});
const data = await res.json();
setResponse(data.data.response);
};
return (
);
}
Node.js Server Integration
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
app.post('/chat', async (req, res) => {
try {
const response = await axios.post(
'https://broke-o2-api.vercel.app/api/ai/chat',
{
message: req.body.message,
webSearch: true,
temperature: 0.7
},
{
headers: {
'X-API-Key': process.env.BROKE_API_KEY
}
}
);
res.json(response.data);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
PHP Integration
<?php
$apiKey = 'YOUR_API_KEY_HERE';
$data = array(
'message' => 'Hello from PHP!',
'webSearch' => true,
'temperature' => 0.7
);
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n" .
"X-API-Key: $apiKey\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents(
'https://broke-o2-api.vercel.app/api/ai/chat',
false,
$context
);
$response = json_decode($result, true);
echo $response['data']['response'];
?>