API Documentation

Explore the available endpoints

1. Submit Task

**POST** /task/submit

This endpoint allows a user to submit a task for processing. It verifies the user's authentication, checks permissions, freezes credits, and adds the task to the task manager.

Request Body

Request Body Example
{ "authkey": "user_auth_token", "task_type": "model_training", "model_id": "12345", "task_details": { "key1": "value1", "key2": "value2" } }
Field Type Description
authkey string The authentication token for the user.
task_type string The type of task being submitted (e.g., "model_training").
model_id string The ID of the model associated with the task.
task_details object Additional details about the task (e.g., parameters).

Response

Success (200)
{ "message": "Task submitted successfully", "code": 200, "data": { "transaction_id": "txn_1234567890" } }
Error Response (400)
{ "message": "Invalid task type", "code": 400, "data": {} }
Error Response (401)
{ "message": "Invalid authkey", "code": 401, "data": {} }
Error Response (403)
{ "message": "Permission denied", "code": 403, "data": {} }
Error Response (429)
{ "message": "Rate limit exceeded", "code": 429, "data": {} }
Error Response (400 - Credits)
{ "message": "Failed to freeze credits: Insufficient balance", "code": 400, "data": {} }

2. Query Task

**POST** /task/query

This endpoint allows a user to query the status of a task using the transaction ID. If the task has finished, the details will be returned; otherwise, the status will be "pending".

Request Body

Request Body Example
{ "authkey": "user_auth_token", "transaction_id": "txn_1234567890" }
Field Type Description
authkey string The authentication token for the user.
transaction_id string The transaction ID of the task to query.

Response

Success (200) - Task Found
{ "message": "Task finished", "code": 200, "data": { "task_type": "model_training", "transaction_id": "txn_1234567890", "status": "completed", "task_details": { "key1": "value1", "key2": "value2" } } }
Success (100) - Task Pending
{ "message": "Task status", "code": 100, "data": { "task_type": "model_training", "transaction_id": "txn_1234567890", "status": "pending", "task_details": { "key1": "value1", "key2": "value2" } } }
Error Response (404 - User Not Found)
{ "message": "User not found", "code": 404, "data": {} }
Error Response (401 - Invalid Authkey)
{ "message": "Invalid authkey", "code": 401, "data": {} }
Error Response (404 - Task Not Found)
{ "message": "Task not found", "code": 404, "data": {} }

Error Codes

Code Description
200 Success: The operation was successful.
100 Task is still pending.
400 Bad Request: General error, such as invalid input.
401 Unauthorized: The authkey is invalid or missing.
403 Forbidden: The user does not have permission.
404 Not Found: The specified resource does not exist.
429 Too Many Requests: Rate limit exceeded.