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

API Documentation

Programmatic access to Video AI functionality

Authentication Required

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

GET

/api/stats

Get real-time system statistics including CPU usage, RAM consumption, and GPU information.

Curl Example

curl -H "Authorization: Bearer YOUR_API_TOKEN" {{ request.host_url }}api/stats

Response

{ "status": "Idle", "gpu_count": 1, "gpus": [ { "name": "NVIDIA RTX 3080", "memory_used": 0.5, "memory_total": 10.0, "utilization": 0 } ], "cpu_percent": 15.2, "ram_used": 4.2, "ram_total": 16.0 }
POST

/api/analyze

Perform AI-powered media analysis using advanced language models. Costs 10 tokens (free for admins).

Parameters

model_path string (optional)
AI model to use (default: "Qwen/Qwen2.5-VL-7B-Instruct")
prompt string (optional)
Analysis prompt (default: "Describe this image.")
file file upload (required*)
Media file to upload and analyze
file_path string (admin only)
Path to existing media file on server (admin users only)
interval integer (optional)
Frame sampling interval for videos (default: 10)
upload_id string (optional)
Unique identifier for chunked uploads
chunk_number integer (optional)
Current chunk number (0-based) for chunked uploads
total_chunks integer (optional)
Total number of chunks for chunked uploads
filename string (optional)
Original filename for chunked uploads
Note: Either file upload or file_path (admin only) must be provided. Chunked uploads are supported for large files.

Curl Examples

File Upload:
curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "model_path=Qwen/Qwen2.5-VL-7B-Instruct" \ -F "prompt=Describe this video" \ -F "interval=30" \ -F "file=@/path/to/video.mp4" \ {{ request.host_url }}api/analyze
File Path (Admin Only):
curl -X POST -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \ -F "model_path=Qwen/Qwen2.5-VL-7B-Instruct" \ -F "prompt=Describe this video" \ -F "file_path=/server/path/to/video.mp4" \ -F "interval=30" \ {{ request.host_url }}api/analyze
Chunked Upload:
# Upload file in chunks (useful for large files) # First chunk curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "upload_id=my_upload_123" \ -F "chunk_number=0" \ -F "total_chunks=3" \ -F "filename=large_video.mp4" \ -F "file=@chunk_0.mp4" \ {{ request.host_url }}api/analyze # Second chunk curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "upload_id=my_upload_123" \ -F "chunk_number=1" \ -F "total_chunks=3" \ -F "filename=large_video.mp4" \ -F "file=@chunk_1.mp4" \ {{ request.host_url }}api/analyze # Final chunk (triggers analysis) curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "upload_id=my_upload_123" \ -F "chunk_number=2" \ -F "total_chunks=3" \ -F "filename=large_video.mp4" \ -F "model_path=Qwen/Qwen2.5-VL-7B-Instruct" \ -F "prompt=Describe this video" \ -F "file=@chunk_2.mp4" \ {{ request.host_url }}api/analyze

Response

{ "result": "Analysis result here...", "tokens_used": 10, "remaining_tokens": 90 }
GET

/api/api_tokens

Retrieve a list of your active API tokens for programmatic access.

Curl Example

curl -H "Authorization: Bearer YOUR_API_TOKEN" {{ request.host_url }}api/api_tokens

Response

{ "tokens": [ { "id": 1, "name": "My Token", "created_at": "2024-01-01T00:00:00Z", "last_used": null } ] }
{% endblock %}