Task Schemas

Tasks in Autoken are defined using a simplified JSON schema format. This page documents the schema structure and conventions.

Overview

Each task is defined in a JSON file with the following structure:

{
  "name": "task-name",
  "description": "Human-readable description of the task",
  "category": "category-name",
  "icon": "lucide-icon-name",
  "pricingModel": { ... },
  "input": { ... },
  "output": { ... },
  "schemas": { ... },
  "methods": { ... }
}

Simplified Schema Format

The input and output fields use a simplified format where each field is defined directly without wrapping in properties.

✓ Simplified Format

{
  "input": {
    "query": {
      "type": "string",
      "description": "Search query",
      "required": true
    },
    "limit": {
      "type": "number",
      "default": 10
    }
  }
}

✗ Old Format (Not Used)

{
  "inputSchema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string"
      }
    },
    "required": ["query"]
  }
}

Key differences: In the simplified format, fields are defined directly under input/output, and required: true is set on individual fields instead of a separate array.

Field Types

TypeDescriptionExample
stringText values"hello"
numberNumeric values (integer or float)42, 3.14
booleanTrue/false valuestrue
objectNested structured data{ "key": "value" }
arrayLists of items[1, 2, 3]
artifactBinary file reference (SHA-256 hash)"abc123..."
schemaData structure definition{ "type": "object", ... }

Field Properties

required

Set to true to mark a field as required.

"query": { "type": "string", "required": true }

default

Specify a default value for optional fields.

"limit": { "type": "number", "default": 10 }

description

Human-readable description of the field.

"query": { "type": "string", "description": "The search query" }

enum

Restrict values to a specific set of options.

"format": { "type": "string", "enum": ["mp3", "wav", "ogg"] }

items

Define the type of items in an array.

"tags": { "type": "array", "items": { "type": "string" } }

Pricing Model

The pricingModel field defines how the task is priced. Providers set actual USD prices when they register.

{
  "pricingModel": {
    "unit": "megabyte",
    "unitLabel": "MB",
    "outputField": "megabytesUsed",
    "modifiers": {
      "type": ["datacenter", "residential", "mobile"]
    }
  }
}
FieldDescription
unitUnit of measurement (e.g., "request", "character", "megabyte", "second")
unitLabelHuman-readable label for the unit
inputFieldInput field used for cost calculation
outputFieldOutput field used for cost calculation
modifiersInput options that affect pricing (e.g., quality tiers)

Exported Schemas

Tasks can export reusable schemas that other tasks can reference using the schemas field.

{
  "name": "social-search",
  "schemas": {
    "post": {
      "platform": { "type": "string", "required": true },
      "content": { "type": "string", "required": true },
      "url": { "type": "string", "required": true },
      "author": { "type": "string" },
      "timestamp": { "type": "string" }
    }
  },
  "output": {
    "results": {
      "type": "array",
      "items": { "$ref": "#/schemas/post" }
    }
  }
}

Reference Formats

  • #/schemas/post - Reference a schema within the same task
  • social-search.post - Reference a schema from another task

Task Methods

Methods allow operations on an existing task execution. They're defined in the methods field.

{
  "name": "proxy-rent",
  "methods": {
    "extend": {
      "description": "Extend an existing proxy rental",
      "input": {
        "duration": { 
          "type": "number", 
          "description": "Additional seconds", 
          "required": true 
        }
      },
      "output": {
        "expiresAt": { "type": "string" },
        "additionalCost": { "type": "number" }
      }
    }
  }
}

Complete Example

{
  "name": "translate-text",
  "description": "Translate text between languages",
  "category": "language",
  "icon": "languages",
  "pricingModel": {
    "unit": "character",
    "unitLabel": "char",
    "inputField": "text"
  },
  "input": {
    "text": {
      "type": "string",
      "description": "Text to translate",
      "required": true
    },
    "language": {
      "type": "string",
      "description": "Target language code (e.g., 'es', 'fr', 'de')",
      "required": true
    },
    "sourceLanguage": {
      "type": "string",
      "description": "Source language (auto-detected if not specified)"
    }
  },
  "output": {
    "translatedText": {
      "type": "string",
      "description": "The translated text"
    },
    "detectedLanguage": {
      "type": "string",
      "description": "The detected source language"
    },
    "characterCount": {
      "type": "number",
      "description": "Number of characters translated"
    }
  }
}