Memeputer

Output Schema

The outputSchema in your 402 response tells x402.jobs what inputs your resource accepts and what outputs it produces. This enables automatic form generation and field mapping in workflows.

Schema Structure

{
  "outputSchema": {
    "input": {
      "type": "http",
      "method": "POST",
      "bodyType": "json",
      "bodyFields": { ... },
      "queryParams": { ... }
    },
    "output": { ... }
  }
}

Input Schema

For POST Requests (bodyFields)

{
  "input": {
    "type": "http",
    "method": "POST",
    "bodyType": "json",
    "bodyFields": {
      "prompt": {
        "type": "string",
        "required": true,
        "description": "The prompt for image generation"
      },
      "style": {
        "type": "string",
        "required": false,
        "description": "Art style",
        "enum": ["realistic", "anime", "cartoon"],
        "default": "realistic"
      },
      "width": {
        "type": "integer",
        "required": false,
        "description": "Image width in pixels",
        "default": 1024
      }
    }
  }
}

For GET Requests (queryParams)

{
  "input": {
    "type": "http",
    "method": "GET",
    "queryParams": {
      "symbol": {
        "type": "string",
        "required": true,
        "description": "Token symbol (e.g., SOL, BTC)"
      },
      "timeframe": {
        "type": "string",
        "required": false,
        "description": "Time period",
        "enum": ["1h", "24h", "7d", "30d"],
        "default": "24h"
      }
    }
  }
}

Field Properties

PropertyTypeDescription
typestring"string", "integer", "number", "boolean", "array", "object"
requiredbooleanWhether the field is required
descriptionstringHuman-readable description (shown in UI)
defaultanyDefault value if not provided
enumarrayList of allowed values (creates a dropdown)

Output Schema

Describe what your resource returns:

{
  "output": {
    "imageUrl": {
      "type": "string",
      "description": "URL to the generated image"
    },
    "prompt": {
      "type": "string",
      "description": "The prompt that was used"
    },
    "metadata": {
      "type": "object",
      "description": "Additional generation metadata",
      "properties": {
        "seed": { "type": "integer" },
        "model": { "type": "string" }
      }
    }
  }
}

UI Generation

x402.jobs uses your schema to generate forms:

  • string → Text input
  • string with enum → Dropdown select
  • integer/number → Number input
  • boolean → Toggle switch
  • required: true → Field marked with asterisk

Workflow Field Mapping

When users connect nodes, they can map fields:

[Trigger: prompt] → [Your Resource: prompt]
[Your Resource: imageUrl] → [Output: display]

The output schema enables autocomplete for field names.

Complete Example

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "solana",
    "maxAmountRequired": "100000",
    "resource": "https://api.example.com/generate-image",
    "payTo": "YourWallet...",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "description": "Generate AI images from text prompts",
    "mimeType": "application/json",
    "maxTimeoutSeconds": 60,
    "outputSchema": {
      "input": {
        "type": "http",
        "method": "POST",
        "bodyType": "json",
        "bodyFields": {
          "prompt": {
            "type": "string",
            "required": true,
            "description": "Describe the image you want"
          },
          "negativePrompt": {
            "type": "string",
            "required": false,
            "description": "What to avoid in the image"
          },
          "aspectRatio": {
            "type": "string",
            "required": false,
            "enum": ["1:1", "16:9", "9:16"],
            "default": "1:1",
            "description": "Image aspect ratio"
          }
        }
      },
      "output": {
        "imageUrl": {
          "type": "string",
          "description": "URL to generated image"
        },
        "revised_prompt": {
          "type": "string",
          "description": "The prompt after AI enhancement"
        }
      }
    },
    "extra": {
      "serviceName": "ImageGen Pro",
      "avatarUrl": "https://example.com/logo.png"
    }
  }]
}

Tips

  1. Be descriptive - Good descriptions help users understand fields
  2. Use enums - When there are fixed options, list them
  3. Set defaults - Reduce friction for optional fields
  4. Document outputs - Help users map fields in workflows