Complete reference for integrating AI Copilot Pro into your applications. All endpoints require authentication via Bearer token.
Overview
https://api.aicopilot.pro (or your self-hosted domain). All responses return JSON.
Authentication
All authenticated endpoints require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_ACCESS_TOKEN
Rate Limits
Rate limits are applied per-user based on your subscription tier. If you exceed the limit, you will receive a 429 Too Many Requests response.
Error Format
{
"detail": "Error message describing what went wrong"
}
Authentication
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | required | User email address | |
| password | string | required | User password |
"user": object // { id, email, created_at }
curl -X POST https://api.aicopilot.pro/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "your-password"
}'
import requests
resp = requests.post("https://api.aicopilot.pro/auth/login", json={
"email": "user@example.com",
"password": "your-password"
})
data = resp.json()
token = data["access_token"]
print(f"Token: {token}")
const resp = await fetch('https://api.aicopilot.pro/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'user@example.com',
password: 'your-password'
})
});
const data = await resp.json();
console.log('Token:', data.access_token);
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | required | Email address | |
| password | string | required | Password (min 8 characters) |
"user": object // { id, email, created_at }
curl -X POST https://api.aicopilot.pro/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "new@example.com",
"password": "secure-password"
}'
import requests
resp = requests.post("https://api.aicopilot.pro/auth/register", json={
"email": "new@example.com",
"password": "secure-password"
})
data = resp.json()
token = data["access_token"]
const resp = await fetch('https://api.aicopilot.pro/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'new@example.com',
password: 'secure-password'
})
});
const data = await resp.json();
console.log('Token:', data.access_token);
"email": string
"created_at": string // ISO 8601 datetime
Chat Completions
stream: true to receive real-time token delivery.
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | string | required | The user message to send |
| session_id | string | optional | Conversation session ID for context continuity |
| stream | boolean | optional | Enable SSE streaming (default: false) |
Non-streaming Response
"content": string // Full response text
"model": string
"usage": object // { input_tokens, output_tokens, cost_usd }
SSE Stream Events
When stream: true, the response is a stream of data: ... lines. Each line contains a JSON object with a type field:
data: {"type": "delta", "content": "Hello"}
data: {"type": "delta", "content": " world"}
data: {"type": "cost", "input_tokens": 12, "output_tokens": 45, "cost_usd": 0.0023}
data: {"type": "done", "session_id": "abc123"}
data: [DONE]
curl -X POST https://api.aicopilot.pro/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"message": "Explain quantum computing",
"stream": true
}'
import requests
resp = requests.post(
"https://api.aicopilot.pro/v1/chat/completions",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
json={
"message": "Explain quantum computing",
"stream": True,
},
stream=True,
)
for line in resp.iter_lines():
if not line or not line.startswith(b"data: "):
continue
data = line[6:].decode()
if data == "[DONE]":
break
import json
event = json.loads(data)
if event["type"] == "delta":
print(event["content"], end="", flush=True)
elif event["type"] == "cost":
print(f"\nCost: ${event['cost_usd']:.4f}")
const resp = await fetch('https://api.aicopilot.pro/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token,
},
body: JSON.stringify({
message: 'Explain quantum computing',
stream: true,
}),
});
const reader = resp.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith('data: ')) continue;
const data = line.slice(6).trim();
if (data === '[DONE]') { console.log('\nDone'); return; }
const event = JSON.parse(data);
if (event.type === 'delta') process.stdout.write(event.content);
if (event.type === 'cost') console.log(`Cost: ${event.cost_usd.toFixed(4)}`);
}
}
Sessions
[{ "id": string, "title": string, "created_at": string, "updated_at": string }]
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | string | optional | Session title (auto-generated if omitted) |
"title": string
"created_at": string
"title": string
"messages": array // Message history
"created_at": string
Models
[{ "id": string, "name": string, "provider": string }]
curl https://api.aicopilot.pro/v1/models \
-H "Authorization: Bearer YOUR_TOKEN"
import requests
resp = requests.get(
"https://api.aicopilot.pro/v1/models",
headers={"Authorization": f"Bearer {token}"},
)
models = resp.json()["data"]
for m in models:
print(f"{m['id']} — {m['name']}")
const resp = await fetch('https://api.aicopilot.pro/v1/models', {
headers: { 'Authorization': 'Bearer ' + token }
});
const { data: models } = await resp.json();
models.forEach(m => console.log(`${m.id} — ${m.name}`));
Subscriptions
[{ "id": string, "name": string, "price_usd": number, "monthly_credits_usd": number, "features": array }]
| Parameter | Type | Required | Description |
|---|---|---|---|
| plan_id | string | required | The plan ID to subscribe to |
| Parameter | Type | Required | Description |
|---|---|---|---|
| pack_type | string | required | Pack type identifier (e.g., "small", "medium", "large") |
User & Usage
"monthly_usd": number // Remaining monthly credits
"pack_usd": number // Remaining pack credits
"total_usd": number // Sum of all pools
curl https://api.aicopilot.pro/user/token-balance \
-H "Authorization: Bearer YOUR_TOKEN"
import requests
resp = requests.get(
"https://api.aicopilot.pro/user/token-balance",
headers={"Authorization": f"Bearer {token}"},
)
balance = resp.json()
print(f"Total: ${balance['total_usd']:.2f}")
const resp = await fetch('https://api.aicopilot.pro/user/token-balance', {
headers: { 'Authorization': 'Bearer ' + token }
});
const balance = await resp.json();
console.log(`Total: $${balance.total_usd.toFixed(2)}`);
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | integer | optional | Page number (default: 1) |
| per_page | integer | optional | Items per page (default: 20, max: 100) |
[{ "model": string, "input_tokens": integer, "output_tokens": integer, "cost_usd": number, "created_at": string }]
"total": integer // Total record count
"page": integer
"per_page": integer
Pricing
Per-model pricing for API usage. Credits are consumed in USD equivalent.
| Model | Input (per 1K tokens) | Output (per 1K tokens) | Provider |
|---|---|---|---|
| Loading pricing... | |||
API Tester
Send real API requests directly from this page. Enter your API key and select an endpoint to test.