Tasks API

Complete API reference for creating, managing, and executing ML tasks across the bridge network.

Overview

The Tasks API enables users to create, submit, and manage machine learning tasks that can be executed across different compute providers in the bridge network. Tasks represent computational work that needs to be performed using registered ML models.

Task Lifecycle

1

Created

Task submitted to network

2

Assigned

Matched with compute provider

3

Executing

Running on compute infrastructure

4

Completed

Results available for retrieval

Endpoints

GET /api/tasks

Retrieve a paginated list of tasks with optional filtering by status, model, or user.

Query params: page, limit, status, model_id, user_address

POST /api/tasks

Create a new ML task with input data, model selection, and execution parameters.

Required: model_id, input_data, compute_requirements

GET /api/tasks/{id}

Get detailed information about a specific task including status, results, and execution logs.

POST /api/tasks/{id}/cancel

Cancel a pending or executing task. Only available for task creators.

GET /api/tasks/{id}/results

Download the results of a completed task in the specified format.

Query params: format (json, csv, binary)

GET /api/tasks/{id}/logs

Retrieve execution logs and debugging information for a task.

POST /api/tasks/batch

Submit multiple tasks in a single request for batch processing.

Max 100 tasks per batch request

Task Status Codes

Active States

CREATEDTask submitted, awaiting assignment
ASSIGNEDMatched with compute provider
EXECUTINGCurrently running

Final States

COMPLETEDSuccessfully finished
FAILEDExecution error occurred
CANCELLEDCancelled by user

Request Example

Example of creating a new task:

POST /api/tasks Content-Type: application/json Authorization: Bearer YOUR_API_KEY { "model_id": "model_123", "input_data": { "text": "Analyze this sentiment", "parameters": { "temperature": 0.7, "max_tokens": 100 } }, "compute_requirements": { "gpu_memory": "8GB", "max_execution_time": 300 }, "callback_url": "https://your-app.com/webhook/task-complete" }

Response Example

{ "task_id": "task_456", "status": "CREATED", "model_id": "model_123", "created_at": "2025-01-15T10:30:00Z", "estimated_completion": "2025-01-15T10:35:00Z", "cost_estimate": { "amount": "0.05", "currency": "USDC" }, "compute_requirements": { "gpu_memory": "8GB", "max_execution_time": 300 } }

Webhooks

Configure webhook URLs to receive real-time updates about task status changes:

  • Task assignment notifications
  • Execution start/completion events
  • Error and failure alerts
  • Result availability notifications

Rate Limits

Standard Tier

  • 50 tasks per hour
  • 10 concurrent executions
  • 5 batch requests per hour

Premium Tier

  • 500 tasks per hour
  • 50 concurrent executions
  • 25 batch requests per hour

Error Handling

Common error responses and their meanings:

400 Bad RequestInvalid task parameters or input data
402 Payment RequiredInsufficient balance for task execution
404 Not FoundTask or model not found
429 Too Many RequestsRate limit exceeded