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
- Completed Authentication, Wallet Management, Identity Management, and Role Management tutorials
- Active session and wallet
AI_MODEL_OWNER_ROLEassigned to your identity (see Role Management)
Required Roles
AI Model Owner Role
To register and manage AI models, you need the following roles:
| Role | Purpose | Required For |
|---|---|---|
AI_MODEL_OWNER_ROLE | Register AI models | Creating new model registrations |
AI_MODEL_OPERATOR_ROLE | List and view models | Listing all models and getting model details |
Authorization
You can register AI models if:
- Your identity has
AI_MODEL_OWNER_ROLE(granted byADMIN_ROLE)
You can list and view AI models if:
- Your identity has
AI_MODEL_OPERATOR_ROLE(granted byADMIN_ROLE)
You can update AI models if:
- You own the model (registered it), OR
- You have
AI_MODEL_OPERATOR_ROLEAND 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-modelRequest
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
| Field | Type | Required | Description |
|---|---|---|---|
walletId | string | Yes | Your wallet ID |
password | string | Yes | Wallet password |
did | string | Yes | Your identity DID (format: did:ethr:{network}:0x...) |
name | string | Yes | Model name (max 255 chars) |
description | string | Yes | Model description (max 255 chars) |
uri | string | Yes | Model location URL (max 255 chars) |
version | string | Yes | Model version (max 255 chars) |
Response (200 OK)
{
"id": "0x2d8f5b3a9c6e1f4b7d2a5c8e3f6b9d1a4c7e2f5b8d3a6c9e1f4b7d2a5c8e3f6b"
}Returns the AI model ID (bytes32 hash).
Error Responses
| Code | Error | Cause |
|---|---|---|
| 404 | WALLET_NOT_FOUND | Wallet doesn’t exist |
| 400 | WRONG_PASSWORD | Wallet password incorrect |
| 400 | INVALID_DID | Identity address format invalid |
| 400 | INVALID_NAME | Name empty or > 255 chars |
| 400 | INVALID_DESCRIPTION | Description empty or > 255 chars |
| 400 | INVALID_URI | URI empty or > 255 chars |
| 400 | INVALID_VERSION | Version empty or > 255 chars |
| 403 | INVALID_WALLET | Wallet doesn’t belong to you |
| 500 | TRANSACTION_ERROR | Blockchain 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
| Code | Error | Cause |
|---|---|---|
| 403 | AI_MODEL_OPERATOR_ROLE_REQUIRED | Your 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_ROLEAND 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
- Benchmarking - Benchmark your models on registered hardware
- Marketplace - Trade AI models
Related Topics
- Dataset Registration - Register training datasets
- Resource Access Control - Same access control patterns
- Hardware Registration - Register hardware for model inference