Skip to content
7. AI Model Registration

7. AI Model Registration

This tutorial covers registering AI models in the dAIEDGE Middleware with ownership tracking and version management.

Overview

AI model registration allows you to:

  • Publish trained models to the blockchain
  • Track model versions
  • Control access to proprietary models
  • Enable model discovery for benchmarking
  • Establish model ownership

Prerequisites


Required Roles

AI Model Owner Role

To register and manage AI models, you need the following roles:

RolePurposeRequired For
AI_MODEL_OWNER_ROLERegister AI modelsCreating new model registrations
AI_MODEL_OPERATOR_ROLEList and view modelsListing all models and getting model details

Authorization

You can register AI models if:

  • Your identity has AI_MODEL_OWNER_ROLE (granted by ADMIN_ROLE)

You can list and view AI models if:

  • Your identity has AI_MODEL_OPERATOR_ROLE (granted by ADMIN_ROLE)

You can update AI models if:

  • You own the model (registered it), OR
  • You have AI_MODEL_OPERATOR_ROLE AND are a valid delegate of the model owner (via Identity Management)

See the Role Management tutorial to obtain these roles.


Step 1: Register AI Model

Endpoint

POST /api/v1/ai-model

Request

curl -X POST https://middleware-daiedge.bisite.usal.es/api/v1/ai-model \
  -H "Content-Type: application/json" \
  -H "x-session-id: {SESSION_ID}" \
  -d '{
    "walletId": "0000019e7f4d2b9a5c8e1f3d6b9a2c5e",
    "password": "WalletPass123!",
    "did": "did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
    "name": "ResNet-50-ImageNet",
    "description": "ResNet-50 trained on ImageNet-1K",
    "uri": "https://models.example.com/resnet50-imagenet",
    "version": "1.0.0"
  }'

Request Body

FieldTypeRequiredDescription
walletIdstringYesYour wallet ID
passwordstringYesWallet password
didstringYesYour identity DID (format: did:ethr:{network}:0x...)
namestringYesModel name (max 255 chars)
descriptionstringYesModel description (max 255 chars)
uristringYesModel location URL (max 255 chars)
versionstringYesModel version (max 255 chars)

Response (200 OK)

{
  "id": "0x2d8f5b3a9c6e1f4b7d2a5c8e3f6b9d1a4c7e2f5b8d3a6c9e1f4b7d2a5c8e3f6b"
}

Returns the AI model ID (bytes32 hash).

Error Responses

CodeErrorCause
404WALLET_NOT_FOUNDWallet doesn’t exist
400WRONG_PASSWORDWallet password incorrect
400INVALID_DIDIdentity address format invalid
400INVALID_NAMEName empty or > 255 chars
400INVALID_DESCRIPTIONDescription empty or > 255 chars
400INVALID_URIURI empty or > 255 chars
400INVALID_VERSIONVersion empty or > 255 chars
403INVALID_WALLETWallet doesn’t belong to you
500TRANSACTION_ERRORBlockchain transaction failed (check you have AI_MODEL_OWNER_ROLE)

Step 2: List AI Models

Requires AI_MODEL_OPERATOR_ROLE.

Endpoint

GET /api/v1/ai-model?userDID={userDID}&page={page}

Request

curl -X GET "https://middleware-daiedge.bisite.usal.es/api/v1/ai-model?userDID=did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7&page=1" \
  -H "x-session-id: {SESSION_ID}"

Response (200 OK)

{
  "models": [
    {
      "id": "0x2d8f5b3a9c6e1f4b7d2a5c8e3f6b9d1a4c7e2f5b8d3a6c9e1f4b7d2a5c8e3f6b",
      "owner": "did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
      "name": "ResNet-50-ImageNet",
      "description": "ResNet-50 trained on ImageNet-1K",
      "uri": "https://models.example.com/resnet50-imagenet",
      "version": "1.0.0",
      "created": 1697000000000
    }
  ],
  "page": 1,
  "totalPages": 8,
  "total": 195
}

Error Responses

CodeErrorCause
403AI_MODEL_OPERATOR_ROLE_REQUIREDYour identity lacks AI_MODEL_OPERATOR_ROLE

Step 3: Get AI Model Details

Requires AI_MODEL_OPERATOR_ROLE.

Endpoint

GET /api/v1/ai-model/{id}?userDID={userDID}

Request

curl -X GET "https://middleware-daiedge.bisite.usal.es/api/v1/ai-model/{MODEL_ID}?userDID=did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7" \
  -H "x-session-id: {SESSION_ID}"

Response (200 OK)

{
  "owner": "did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
  "hash": "0x2d8f5b3a9c6e1f4b7d2a5c8e3f6b9d1a4c7e2f5b8d3a6c9e1f4b7d2a5c8e3f6b",
  "name": "ResNet-50-ImageNet",
  "description": "ResNet-50 trained on ImageNet-1K",
  "uri": "https://models.example.com/resnet50-imagenet",
  "version": "1.0.0",
  "created": 1697000000000
}

Step 4: Update AI Model

Endpoint

POST /api/v1/ai-model/{id}

Request

curl -X POST https://middleware-daiedge.bisite.usal.es/api/v1/ai-model/{MODEL_ID} \
  -H "Content-Type: application/json" \
  -H "x-session-id: {SESSION_ID}" \
  -d '{
    "walletId": "0000019e7f4d2b9a5c8e1f3d6b9a2c5e",
    "password": "WalletPass123!",
    "did": "did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
    "name": "ResNet-50-ImageNet",
    "description": "ResNet-50 trained on ImageNet-1K (updated weights)",
    "uri": "https://models.example.com/resnet50-imagenet-v2",
    "version": "2.0.0"
  }'

Request body fields are the same as Step 1: Register AI Model.

Response (200 OK)

{}

Authorization

You can update an AI model if:

  • You are the model owner (registered it), OR
  • You have AI_MODEL_OPERATOR_ROLE AND are a valid delegate of the owner (via Identity Management)

Access Control for AI Models

AI model access control works identically to hardware and dataset access control. See Hardware Access Control tutorial for details.

Grant Model Access

curl -X POST https://middleware-daiedge.bisite.usal.es/api/v1/access/grant-access \
  -H "Content-Type: application/json" \
  -H "x-session-id: {SESSION_ID}" \
  -d '{
    "walletId": "0000019e7f4d2b9a5c8e1f3d6b9a2c5e",
    "password": "WalletPass123!",
    "userDID": "did:ethr:development:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
    "did": "did:ethr:development:0x8Ba1f109551bD432803012645Ac136ddd64DBA72",
    "resourceId": "0x2d8f5b3a9c6e1f4b7d2a5c8e3f6b9d1a4c7e2f5b8d3a6c9e1f4b7d2a5c8e3f6b",
    "resourceType": "ai_model",
    "expirationTime": 1735689600,
    "usageLimit": 50,
    "indefinite": false
  }'

Next Steps

Related Topics