API Reference
Complete API documentation for Kai the AI
Base URL
All API requests should be made to:
https://chi2api.com/v1
Authentication
Kai uses API keys for authentication. Include your API key in the Authorization header:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://chi2api.com/v1/status
WarningSecurity Note
Never expose your API key in client-side code or public repositories.
Endpoints
Grading
Submit Assignment for Grading
POST /assignments/grade
Request Body:
{
"assignment_id": "string",
"student_submission": "string",
"rubric_id": "string (optional)",
"grading_style": "detailed|concise|points_only"
}Response:
{
"grade_id": "string",
"score": 85,
"feedback": "string",
"suggestions": ["string"],
"timestamp": "2024-01-01T00:00:00Z"
}Example:
import requests
response = requests.post(
"https://chi2api.com/v1/assignments/grade",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"assignment_id": "CS101-HW1",
"student_submission": "Student's essay text here...",
"grading_style": "detailed"
}
)
result = response.json()
print(f"Score: {result['score']}")
print(f"Feedback: {result['feedback']}")const response = await fetch('https://chi2api.com/v1/assignments/grade', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
assignment_id: 'CS101-HW1',
student_submission: 'Student essay text here...',
grading_style: 'detailed'
})
});
const result = await response.json();
console.log(`Score: ${result.score}`);
console.log(`Feedback: ${result.feedback}`);curl -X POST https://chi2api.com/v1/assignments/grade \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"assignment_id": "CS101-HW1",
"student_submission": "Student essay text here...",
"grading_style": "detailed"
}'Content Generation
Generate Quiz Questions
POST /content/quiz
Request Body:
{
"topic": "string",
"difficulty": "easy|medium|hard",
"question_count": 10,
"question_types": ["multiple_choice", "true_false", "short_answer"]
}Analytics
Get Student Performance
GET /analytics/students/{student_id}/performance
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
| start_date | string | ISO 8601 date |
| end_date | string | ISO 8601 date |
| course_id | string | Filter by specific course |
Rate Limits
| Plan | Requests per minute | Requests per day |
|---|---|---|
| Free | 10 | 1,000 |
| Educator | 60 | 10,000 |
| Institution | 300 | 100,000 |
Error Handling
Kai uses standard HTTP response codes:
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
Error Response Format:
{
"error": {
"code": "invalid_parameter",
"message": "The 'assignment_id' field is required",
"details": {}
}
}Webhooks
Configure webhooks to receive real-time updates:
POST /webhooks
{
"url": "https://your-domain.com/webhook",
"events": ["grading.completed", "content.generated"],
"active": true
}SDKs
Official SDKs are available for:
- Python - Python SDK documentation with installation, examples, and API reference
- JavaScript/TypeScript - JavaScript and TypeScript SDK with Node.js and browser support
- Java - Java SDK with Maven/Gradle integration and async support
- Ruby - Ruby SDK with Rails integration and idiomatic patterns
Support
- API Status: status.chi2api.com
- Developer Forum: forum.chi2labs.com
- Email: developers@chi2labs.com