Kiroshi AI Documentation
THIS IS PROTOTYPE THAT MAY NOT WORK
Getting Started
Installation
git clone https://github.com/Kiroshi-Ai/kiroshi-ai
cd kiroshi-ai
docker compose up -d
API Reference
Base URL
The API is accessible at http://localhost:80/
Authentication
All endpoints except /users/register
and /users/login
require JWT authentication via the Authorization header.
Core Dependencies
Component | Purpose |
---|---|
SurrealDB | Database |
Redis | Caching |
Nginx | Web Server |
Rust | Backend |
Loki | Logging |
NATS | Message Queue |
API Endpoints
User Management
Get Users
-
GET /users
- List all users -
GET /users/{user_id}
- Retrieve specific user -
GET /auth
- Get authenticated user info
Authentication
-
POST /users/register
- Create account -
POST /users/login
- Authenticate user -
POST /users/{user_id}/logout
- Invalidate JWT token
Profile Updates
-
POST /users/{user_id}/change-nickname
- Update nickname -
POST /users/{user_id}/change-surname
- Update surname -
POST /users/{user_id}/change-email
- Update email -
POST /users/{user_id}/change-name
- Update name -
POST /users/{user_id}/change-password
- Update password -
DELETE /users/{user_id}
- Delete account (admin/self only)
Other
-
GET /healthy
- Is healthy
Request/Response Examples
Registration
POST /users/register
Request:
{
"email": "string",
"nickname": "string",
"name": "string",
"surname": "string",
"password": "string"
}
Response:
{
"created_user": {
"user_id": "string",
"nickname": "string",
"name": "string",
"surname": "string",
"email": "string"
},
"message": "string"
}
Authentication
POST /users/login
Request:
{
"email": "string",
"password": "string"
}
Response:
{
"message": "string",
"user_id": "string"
}
Profile Updates
POST /users/{user_id}/change-{field}
Request:
{
"new_{field}": "string"
}
Response:
{
"message": "string",
"old_{field}": "string",
"new_{field}": "string"
}
User Info
GET /auth
Response:
{
"user_id": "string",
"nickname": "string",
"name": "string",
"surname": "string",
"email": "string",
"metadata": {
// User metadata fields
}
}
Subscription Management
Get Subscription Plans
-
GET /subscriptions/plans
- List all subscription plans
Get Specific Subscription Plan
-
GET /subscriptions/plans/{id}
- Retrieve specific subscription plan
Create Subscription Plan
-
POST /subscriptions/plans
- Create a new subscription plan
Update Subscription Plan
-
PATCH /subscriptions/plans/{id}
- Update an existing subscription plan
Delete Subscription Plan
-
DELETE /subscriptions/plans/{id}
- Delete a subscription plan
Get Subscribers
-
GET /subscriptions/subscribers
- List all subscribers
Get Specific Subscriber
-
GET /subscriptions/subscribers/{id}
- Retrieve specific subscriber
Create Subscriber
-
POST /subscriptions/subscribers
- Create a new subscriber
Update Subscriber
-
PATCH /subscriptions/subscribers/{id}
- Update an existing subscriber
Delete Subscriber
-
DELETE /subscriptions/subscribers/{id}
- Delete a subscriber
Buy Subscription
-
POST /subscriptions/buy
- Buy a subscription
Refund Subscription
-
POST /subscriptions/refund
- Refund a subscription
Request/Response Examples
Create Subscription Plan
POST /subscriptions/plans
Request:
{
"price": 9.99,
"duration": 30,
"title": "Basic Plan",
"description": "Access to basic features"
}
Response:
{
"message": "Plan created",
"plan": {
"price": 9.99,
"duration": 30,
"title": "Basic Plan",
"description": "Access to basic features"
}
}
Update Subscription Plan
PATCH /subscriptions/plans/{id}
Request:
{
"price": 14.99,
"duration": 60,
"title": "Premium Plan",
"description": "Access to premium features"
}
Response:
{
"message": "Plan updated",
"plan": {
"price": 14.99,
"duration": 60,
"title": "Premium Plan",
"description": "Access to premium features"
}
}
Create Subscriber
POST /subscriptions/subscribers
Request:
{
"user_id": "user123"
}
Response:
{
"message": "Subscriber created",
"subscriber": {
"user_id": "user123"
}
}
Buy Subscription
POST /subscriptions/buy
Request:
{
"plan_id": "plan123",
"transaction_id": "txn123"
}
Response:
{
"message": "Subscription bought",
"contract": "contract details"
}
Refund Subscription
POST /subscriptions/refund
Request:
{
"contract": "contract details"
}
Response:
{
"message": "Subscription refunded",
"ex_contract": "previous contract details"
}
Chat Management
Get Chat Session
-
GET /chats/{user_id}/{chat_id}/session
- Establish a WebSocket connection for a chat session
Parameters:
-
user_id
(path): The ID of the user -
chat_id
(path): The ID of the chat -
auth_token
(param): Token for authentication -
session_token
(param, optional): Session token for the chat session
Response:
-
200 OK
: WebSocket connection established -
401 Unauthorized
: Authentication failed -
404 Not Found
: Chat not found -
500 Internal Server Error
: Server error
Get Chat
-
GET /chats/{user_id}/{chat_id}
- Retrieve a specific chat
Parameters:
-
user_id
(path): The ID of the user -
chat_id
(path): The ID of the chat -
Authorization
(header): Bearer token for authentication
Response:
-
200 OK
: Chat details in JSON format -
401 Unauthorized
: Authentication failed -
404 Not Found
: Chat not found -
500 Internal Server Error
: Server error
Get All Chats
-
GET /chats/{user_id}
- List all chats for a user
Parameters:
-
user_id
(path): The ID of the user -
Authorization
(header): Bearer token for authentication
Response:
-
200 OK
: List of chats in JSON format -
401 Unauthorized
: Authentication failed -
500 Internal Server Error
: Server error
Create Chat
-
POST /chats/{user_id}
- Create a new chat
Parameters:
-
user_id
(path): The ID of the user -
Authorization
(header): Bearer token for authentication -
Request Body
: JSON object containing the model for the chat
Request Example:
{
"model": "gpt-4o-mini" // Always set this value
}
Response:
{
"chat_id": "chat_id"
}