API Documentation

The OmniTensor API provides developers with powerful tools to interact with the decentralized AI ecosystem. With a variety of endpoints available for managing AI models, performing inference tasks, and leveraging decentralized compute resources, the API is designed to facilitate seamless integration of AI functionalities into your decentralized applications (dApps). Below is an example of key API endpoints, usage patterns, and best practices.

1. Authentication

All API requests must include an authentication token in the headers. This token verifies the identity of the user and authorizes access to the OmniTensor network resources.

  • Endpoint: /auth/token

  • Method: POST

  • Description: Generates an authentication token required for all subsequent API calls.

Request Example:

{
  "api_key": "your-api-key",
  "secret": "your-secret-key"
}

Response Example:

{
  "token": "your-authentication-token",
  "expires_in": 3600
}

2. AI Model Management

2.1 Upload AI Model

This endpoint allows developers to upload custom AI models to the OmniTensor network for decentralized hosting and inference.

  • Endpoint: /ai/models/upload

  • Method: POST

  • Description: Uploads a new AI model to the decentralized infrastructure.

Request Example:

{
  "model_name": "Custom Image Classifier",
  "description": "A deep learning model for image classification.",
  "file": "base64-encoded-model-file",
  "config": {
    "framework": "TensorFlow",
    "version": "2.4.0"
  }
}

Response Example:

{
  "model_id": "abc123",
  "status": "Model successfully uploaded"
}

2.2 List Available Models

Retrieve a list of all AI models available to your account.

  • Endpoint: /ai/models

  • Method: GET

  • Description: Lists all AI models currently uploaded to the OmniTensor infrastructure.

Response Example:

[
  {
    "model_id": "abc123",
    "model_name": "Custom Image Classifier",
    "framework": "TensorFlow",
    "version": "2.4.0",
    "created_at": "2024-01-12T10:34:00Z"
  },
  {
    "model_id": "def456",
    "model_name": "Text Summarizer",
    "framework": "PyTorch",
    "version": "1.7.1",
    "created_at": "2024-01-10T08:20:00Z"
  }
]

2.3 Model Inference

Run inference on a deployed AI model using OmniTensor's decentralized GPU network.

  • Endpoint: /ai/models/{model_id}/inference

  • Method: POST

  • Description: Submit an input to an AI model and receive an inference result.

Request Example:

{
  "model_id": "abc123",
  "input_data": "base64-encoded-image-data"
}

Response Example:

{
  "inference_result": {
    "label": "cat",
    "confidence": 0.98
  }
}

3. Decentralized Compute Management

3.1 Allocate GPU Compute Resources

This endpoint allocates decentralized GPU resources for a given AI task.

  • Endpoint: /compute/allocate

  • Method: POST

  • Description: Request decentralized GPU resources for AI model training or inference.

Request Example:

{
  "task_type": "inference",
  "model_id": "abc123",
  "required_gpus": 2,
  "duration": 3600
}

Response Example:

{
  "task_id": "task789",
  "assigned_gpus": 2,
  "estimated_completion_time": "2024-01-12T12:45:00Z"
}

4. Data Management

4.1 Upload Dataset

Upload a dataset for model training or validation. The dataset will be stored in the decentralized infrastructure and can be used by AI models across the network.

  • Endpoint: /data/upload

  • Method: POST

  • Description: Upload a new dataset to the network.

Request Example:

{
  "dataset_name": "ImageNet Subset",
  "description": "A subset of the ImageNet dataset for image classification.",
  "file": "base64-encoded-data-file"
}

Response Example:

{
  "dataset_id": "dataset123",
  "status": "Dataset successfully uploaded"
}

4.2 Retrieve Dataset Metadata

Fetch metadata for a specific dataset stored on the OmniTensor network.

  • Endpoint: /data/{dataset_id}/metadata

  • Method: GET

  • Description: Get metadata details for a particular dataset.

Response Example:

{
  "dataset_id": "dataset123",
  "dataset_name": "ImageNet Subset",
  "size": "10GB",
  "created_at": "2024-01-05T09:00:00Z",
  "description": "A subset of the ImageNet dataset."
}

5. Token and Payment Management

5.1 Check Token Balance

Retrieve the OMNIT token balance for the authenticated account.

  • Endpoint: /account/balance

  • Method: GET

  • Description: Get the OMNIT token balance of your account.

Response Example:

{
  "balance": 1500,
  "currency": "OMNIT"
}

5.2 Transfer Tokens

Transfer OMNIT tokens to another user on the OmniTensor network.

  • Endpoint: /account/transfer

  • Method: POST

  • Description: Transfer OMNIT tokens to another account.

Request Example:

{
  "recipient": "user789",
  "amount": 250
}

Response Example:

{
  "transaction_id": "tx456",
  "status": "Transfer successful"
}

6. Error Handling

All API responses include a standardized error format in case of failures. Below is an example of an error response:

Error Response Example:

{
  "error": {
    "code": 401,
    "message": "Unauthorized. Invalid authentication token."
  }
}

Best Practices

  • Always ensure your authentication token is valid and refreshed periodically to avoid unauthorized access errors.

  • When uploading large models or datasets, split them into manageable chunks to avoid timeouts or memory issues.

  • Monitor compute resource allocation closely for long-running tasks to optimize costs.

  • Use pagination when retrieving large datasets or model lists to avoid overwhelming your application.

Last updated