API Reference
One endpoint. Send a prompt, get a response. Authenticate with your Client Key + Secret from your Profile.
Quick Start
curl -s -X POST /api/chat.php \
-H "Content-Type: application/json" \
-H "X-Client-Key: ck_YOUR_CLIENT_KEY" \
-H "X-Client-Secret: cs_YOUR_CLIENT_SECRET" \
-d '{
"prompt": "Explain REST APIs in one sentence.",
"model": "covalid-1.0"
}'
<?php
$ch = curl_init('/api/chat.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Client-Key: ck_YOUR_CLIENT_KEY',
'X-Client-Secret: cs_YOUR_CLIENT_SECRET',
],
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Explain REST APIs in one sentence.',
'model' => 'covalid-1.0',
]),
]);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
echo $data['response'];
const res = await fetch('/api/chat.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Client-Key': 'ck_YOUR_CLIENT_KEY',
'X-Client-Secret': 'cs_YOUR_CLIENT_SECRET',
},
body: JSON.stringify({
prompt: 'Explain REST APIs in one sentence.',
model: 'covalid-1.0',
}),
});
const data = await res.json();
console.log(data.response);
import requests
response = requests.post(
'/api/chat.php',
headers={
'X-Client-Key': 'ck_YOUR_CLIENT_KEY',
'X-Client-Secret': 'cs_YOUR_CLIENT_SECRET',
},
json={
'prompt': 'Explain REST APIs in one sentence.',
'model': 'covalid-1.0',
},
)
data = response.json()
print(data['response'])
Endpoint
POST
/api/chat.php
Request Headers
| Header | Required | Description |
|---|---|---|
Content-Type |
required | Must be application/json |
X-Client-Key |
required | Your ck_… client key |
X-Client-Secret |
required | Your cs_… client secret |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
prompt |
string | required | The message / question to send |
model |
string | optional |
Model name. Defaults to covalid-1.0.Available: covalid-1.0
covalid-2.0
|
Response Fields
| Field | Type | Description |
|---|---|---|
response | string | The model's reply |
model | string | Model name that was used (e.g. covalid-2.0) |
elapsed_ms | number | Wall-clock time in milliseconds |
prompt_tokens | number | Tokens in the prompt |
completion_tokens | number | Tokens in the response |
total_tokens | number | Sum of prompt + completion |
done | boolean | Always true (non-streaming) |
HTTP Status Codes
| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Missing or invalid prompt |
| 401 | Invalid or missing credentials |
| 405 | Non-POST request |
| 502 | Ollama unreachable or bad response |
| 503 | Server/proxy overloaded |
Sample — 200 OK
{
"response": "REST stands for Representational State Transfer...",
"model": "covalid-1.0",
"elapsed_ms": 1342,
"done": true,
"prompt_tokens": 12,
"completion_tokens": 38,
"total_tokens": 50
}
Sample — 401 Unauthorized
{
"error": "Invalid client_key or client_secret.",
"auth_required": true
}
Sample — 400 Bad Request
{
"error": "Missing \"prompt\" in request body."
}
Live Tester
Send a real request right from this page. Sign in to pre-fill your credentials.
Response