Skip to content

Models API

API endpoints for managing AI models on WasiAI.


Endpoints

Endpoint Method Description
/api/indexed/models GET List all models (cached)
/api/models/{id} GET Get model details
/api/models/publish POST Publish a new model
/api/models/{id}/update PUT Update model metadata

List Models

Get a list of all published models from the indexed cache.

Request

GET /api/indexed/models

Query Parameters

Parameter Type Default Description
page number 1 Page number
limit number 20 Items per page (max 100)
category string - Filter by category
search string - Search in name/description
sort string newest Sort: newest, popular, price_asc, price_desc

Response

{
  "ok": true,
  "models": [
    {
      "modelId": 1,
      "name": "Crypto Sentiment Analyzer",
      "description": "Analyzes sentiment of crypto news...",
      "category": "sentiment-analysis",
      "coverImage": "ipfs://Qm...",
      "owner": "0x1234...5678",
      "creator": "0x1234...5678",
      "priceInference": "10000",
      "pricePerpetual": "50000000",
      "priceSubscription": "10000000",
      "listed": true,
      "agentId": 1,
      "inferenceCount": 1250,
      "reputationScore": 92
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 45,
    "pages": 3
  }
}

Get Model

Get detailed information about a specific model.

Request

GET /api/models/{id}

Path Parameters

Parameter Type Description
id number Model ID

Response

{
  "ok": true,
  "model": {
    "modelId": 1,
    "name": "Crypto Sentiment Analyzer",
    "description": "Analyzes sentiment of crypto news and social media posts using FinBERT.",
    "uri": "ipfs://QmMetadata...",
    "category": "sentiment-analysis",
    "coverImage": "ipfs://QmCover...",
    "owner": "0x1234567890abcdef1234567890abcdef12345678",
    "creator": "0x1234567890abcdef1234567890abcdef12345678",
    "royaltyBps": 1000,
    "listed": true,
    "priceInference": "10000",
    "pricePerpetual": "50000000",
    "priceSubscription": "10000000",
    "defaultDurationDays": 30,
    "deliveryRightsDefault": 1,
    "version": 1,
    "termsHash": "0x...",
    "inferenceWallet": "0xSplitter...",
    "agent": {
      "agentId": 1,
      "endpoint": "https://wasiai.io/api/inference/1",
      "wallet": "0x...",
      "active": true,
      "registeredAt": "2024-12-01T00:00:00Z"
    },
    "stats": {
      "inferenceCount": 1250,
      "licensesSold": 15,
      "totalRevenue": "125000000",
      "reputationScore": 92
    },
    "metadata": {
      "modelType": "sentiment-analysis",
      "inputFormat": "text",
      "outputFormat": "json",
      "inferenceEndpoint": "https://your-model-endpoint.com/inference"
    }
  }
}

Error Response (404)

{
  "ok": false,
  "error": "model_not_found",
  "message": "Model 999 not found"
}

Publish Model

Publish a new model to the marketplace. Requires wallet authentication.

Request

POST /api/models/publish
Content-Type: application/json

Body

{
  "name": "Crypto Sentiment Analyzer",
  "slug": "crypto-sentiment",
  "description": "Analyzes sentiment of crypto news...",
  "category": "sentiment-analysis",
  "coverImage": "ipfs://QmCover...",
  "uri": "ipfs://QmMetadata...",
  "royaltyBps": 1000,
  "priceInference": "10000",
  "pricePerpetual": "50000000",
  "priceSubscription": "10000000",
  "defaultDurationDays": 30,
  "deliveryRightsDefault": 1,
  "termsHash": "0x...",
  "inferenceWallet": "0x...",
  "agentEndpoint": "https://wasiai.io/api/inference/1",
  "agentMetadataUri": "ipfs://QmAgent..."
}

Response

{
  "ok": true,
  "modelId": 25,
  "agentId": 25,
  "splitter": "0xSplitter...",
  "transactionHash": "0x..."
}

Validation Errors (400)

{
  "ok": false,
  "error": "validation_error",
  "message": "Name is required",
  "fields": {
    "name": "Required field"
  }
}

Update Model

Update model metadata. Only the model owner can update.

Request

PUT /api/models/{id}/update
Content-Type: application/json

Body

{
  "name": "Updated Model Name",
  "description": "Updated description...",
  "uri": "ipfs://QmNewMetadata..."
}

Response

{
  "ok": true,
  "transactionHash": "0x..."
}

Code Examples

JavaScript/TypeScript

// List models
const response = await fetch('/api/indexed/models?category=sentiment-analysis')
const { models } = await response.json()

// Get model details
const modelRes = await fetch('/api/models/1')
const { model } = await modelRes.json()

// Publish model (requires wallet signature)
const publishRes = await fetch('/api/models/publish', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    name: 'My Model',
    slug: 'my-model',
    // ... other fields
  })
})

Python

import requests

# List models
response = requests.get('https://wasiai.io/api/indexed/models', params={
    'category': 'sentiment-analysis',
    'limit': 10
})
models = response.json()['models']

# Get model details
model_response = requests.get('https://wasiai.io/api/models/1')
model = model_response.json()['model']

Rate Limits

Endpoint Limit Window
GET endpoints 30 requests 1 minute
POST/PUT endpoints 10 requests 1 minute