{% extends 'base.html' %} {% block title %}Admin API Documentation{% endblock %} {% block head %} {% endblock %} {% block content %}

Admin API Documentation

Administrative API endpoints for system management

Admin Authentication Required

All endpoints require admin authentication via login session or admin API token (Bearer token in Authorization header).

GET

/admin/api/browse

Browse files and directories in the configured server directory for administrative purposes.

Parameters

path string (optional)
Directory path to browse (default: root directory)

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ "{{ request.host_url }}admin/api/browse?path=/some/path"

Response

{ "current_path": "/some/path", "items": [ { "name": "file.txt", "path": "/some/path/file.txt", "is_dir": false, "size": 1024 } ] }
POST

/admin/api/train

Start AI model training process. Costs 100 tokens (free for admins).

Parameters

output_model string (optional)
Name for the trained model (default: "MyCustomModel")
description string (optional)
Description of the model
train_path string (required)
Path to the training data directory

Curl Example

curl -X POST -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "output_model": "MyModel", "description": "Custom trained model", "train_path": "/path/to/training/data" }' {{ request.host_url }}admin/api/train

Response

{ "message": "Training completed", "tokens_used": 100, "remaining_tokens": 900 }
GET

/admin/api/users

Retrieve a complete list of all users in the system for administrative management.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}admin/api/users

Response

{ "users": [ { "id": 1, "username": "user1", "email": "user1@example.com", "role": "user", "tokens": 100, "active": true, "created_at": "2024-01-01T00:00:00Z" } ] }
GET

/admin/api/cluster_tokens

List all cluster tokens for distributed processing management.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}admin/api/cluster_tokens

Response

{ "tokens": [ { "id": 1, "name": "Worker Token", "token": "abc123...", "active": true, "created_at": "2024-01-01T00:00:00Z" } ] }
GET

/admin/api/cluster_clients

List all connected cluster clients with their GPU capabilities and status.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}admin/api/cluster_clients

Response

{ "clients": [ { "client_id": "abc123...", "connected_at": 1640995200.0, "last_seen": 1640995300.0, "gpu_info": { "cuda_available": true, "rocm_available": false, "cuda_devices": 1, "rocm_devices": 0, "available_backends": ["cuda"] }, "processes": [ { "name": "analysis_cuda", "status": "active", "weight": 10, "model": "Qwen/Qwen2.5-VL-7B-Instruct" } ] } ] }
GET

/api/admin/cluster_nodes

Get detailed information about all cluster nodes, including connected and recently disconnected nodes.

Curl Example

curl -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ {{ request.host_url }}api/admin/cluster_nodes

Response

{ "master_stats": { "total_nodes": 3, "connected_nodes": 2, "total_workers": 6, "total_active_jobs": 1, "total_completed_jobs": 15, "uptime_seconds": 3600.5 }, "nodes": [ { "token": "abc123...", "token_name": "Worker Node 1", "hostname": "worker1.example.com", "weight": 100, "gpus": 1, "gpu_memory": ["CUDA Device 0: 8GB VRAM"], "total_memory": 8, "workers_available": 2, "ip_address": "192.168.1.100", "connected": true, "last_seen": 1640995300.0, "uptime_seconds": 1800.5, "active_jobs": 1, "completed_jobs": 5 } ] }
POST

/api/admin/cluster_nodes/set_driver

Set the preferred GPU driver (CUDA or ROCm) for a specific cluster node. This preference is saved and reused for future connections from the same hostname + token combination.

Parameters

hostname string (required)
Hostname of the cluster node
token string (required)
Authentication token for the node
driver string (required)
Preferred driver: "cuda" or "rocm"

Curl Example

curl -X POST -H "Authorization: Bearer YOUR_ADMIN_API_TOKEN" \ -F "hostname=worker1.example.com" \ -F "token=abc123..." \ -F "driver=cuda" \ {{ request.host_url }}api/admin/cluster_nodes/set_driver

Response

{ "success": true }
{% endblock %}