{
 "openapi": "3.1.0",
 "info": {
  "title": "Agent Exchange Media",
  "version": "1.0.0",
  "summary": "Pay-per-call AI media and inference on Cloudflare Workers AI, paid with x402 (USDC on Base). No API key.",
  "description": "13 POST routes. Send the JSON body; an unpaid request answers 402 with x402 requirements; sign an EIP-3009 USDC authorization for the amount to 0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c and resend with X-PAYMENT. Each response names the Workers AI model that ran. Failed model calls answer 502 and replay once for free within 10 minutes.",
  "termsOfService": "https://media.agentexchange.work/terms",
  "contact": {
   "name": "Agent Exchange",
   "url": "https://agentexchange.work"
  },
  "x-guidance": "Read the free GET /samples/<route>.json first to see request and response shapes. Prices: /image 0.02, /caption 0.005, /speech 0.01, /transcribe 0.01, /translate 0.002, /summarize 0.002, /embed 0.001, /chat 0.005 (70B 0.02), /classify 0.001, /ocr 0.005, /detect-language 0.001, /batch 1.00, /image-set 5.00 USD in USDC. Pay per call; nothing is subscribed.",
  "x-payment": {
   "protocol": "x402",
   "versions": [
    1,
    2
   ],
   "network": "eip155:8453",
   "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
   "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
   "facilitator": "https://facilitator.payai.network"
  }
 },
 "servers": [
  {
   "url": "https://media.agentexchange.work"
  }
 ],
 "tags": [
  {
   "name": "paid",
   "description": "x402-paid routes (USDC on Base)"
  },
  {
   "name": "free",
   "description": "no payment"
  }
 ],
 "x-discovery": {
  "x402": "https://media.agentexchange.work/.well-known/x402",
  "agent_card": "https://media.agentexchange.work/.well-known/agent-card.json",
  "a2a": "https://media.agentexchange.work/a2a",
  "llms": "https://media.agentexchange.work/llms.txt",
  "mcp": "https://media.agentexchange.work/mcp",
  "ownershipProofs": []
 },
 "paths": {
  "/image": {
   "post": {
    "operationId": "image",
    "summary": "Text to image ($0.02 USDC per call)",
    "description": "Text-to-image on Workers AI: FLUX.1 [schnell], 1024x1024 JPEG, 1-8 steps (fallback Stable Diffusion XL base, PNG). Call it when an agent needs one picture from a text prompt in a few seconds. Body {prompt (<=1,000 chars), steps? (1-8, default 4), seed?}; returns {image_base64, mime, model, seed, steps, took_ms}; add ?format=binary for the image bytes. $0.02 USDC per image. Limits: prompt <= 1,000 characters; steps 1-8; seed 0-4294967295; one image per call. Models: @cf/black-forest-labs/flux-1-schnell, @cf/stabilityai/stable-diffusion-xl-base-1.0.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.020000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "20000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "json",
        "binary"
       ]
      },
      "description": "json (default) or binary image bytes"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "prompt"
        ],
        "properties": {
         "prompt": {
          "type": "string",
          "maxLength": 1000
         },
         "steps": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8,
          "default": 4
         },
         "seed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4294967295
         }
        }
       },
       "example": {
        "prompt": "a lighthouse on a basalt cliff at dawn, thick fog, film grain",
        "steps": 4,
        "seed": 7
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "image_base64": "/9j/4AAQSkZJRg...(JPEG, base64)",
         "mime": "image/jpeg",
         "model": "@cf/black-forest-labs/flux-1-schnell",
         "fallback": false,
         "seed": 7,
         "steps": 4,
         "took_ms": 2900
        }
       },
       "image/jpeg": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       },
       "image/png": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/caption": {
   "post": {
    "operationId": "caption",
    "summary": "Image caption ($0.005 USDC per call)",
    "description": "Image to caption: LLaVA 1.5 7B (fallback Llama 3.2 11B Vision) describes the picture in one or two sentences. Use it to label, alt-text or index images. Body {image_url (https, <=5 MB, fetched within 8 s)} or {image_base64}, optional prompt (<=500 chars); or POST the raw image bytes with an image/* content type. Returns {caption, model, took_ms}. $0.005 USDC per image. Limits: image <= 5 MB (JPEG, PNG, WebP, GIF); image_url fetched in 8 s from a public https host; prompt <= 500 characters. Models: @cf/llava-hf/llava-1.5-7b-hf, @cf/meta/llama-3.2-11b-vision-instruct.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "5000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "image_url": {
          "type": "string",
          "format": "uri"
         },
         "image_base64": {
          "type": "string"
         },
         "prompt": {
          "type": "string",
          "maxLength": 500
         }
        }
       },
       "example": {
        "image_url": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "caption": "A tabby cat sits on a wooden floor looking directly at the camera.",
         "model": "@cf/llava-hf/llava-1.5-7b-hf",
         "fallback": false,
         "image_bytes": 154229,
         "source": "url",
         "took_ms": 1800
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/speech": {
   "post": {
    "operationId": "speech",
    "summary": "Text to speech ($0.01 USDC per call)",
    "description": "Text to speech: MeloTTS returns MP3 audio for up to 2,000 characters (lang en, es, fr, zh, ja, ko; fallback Deepgram Aura-1, English, for texts under 600 characters). Body {text, lang?}; the response is audio/mpeg bytes with X-Model and X-Chars headers, or JSON {audio_base64, mime, model} with ?format=json. $0.01 USDC per call. Limits: text <= 2,000 characters; lang one of en, es, fr, zh, ja, ko (default en). Models: @cf/myshell-ai/melotts, @cf/deepgram/aura-1.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.010000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "10000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "binary",
        "json"
       ]
      },
      "description": "binary (default): audio/mpeg bytes; json: {audio_base64}"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "text"
        ],
        "properties": {
         "text": {
          "type": "string",
          "maxLength": 2000
         },
         "lang": {
          "type": "string",
          "enum": [
           "en",
           "es",
           "fr",
           "zh",
           "ja",
           "ko"
          ],
          "default": "en"
         }
        }
       },
       "example": {
        "text": "Your order has shipped and will arrive on Thursday.",
        "lang": "en"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "audio_base64": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4...(MP3, base64)",
         "mime": "audio/mpeg",
         "model": "@cf/myshell-ai/melotts",
         "fallback": false,
         "lang": "en",
         "chars": 52,
         "took_ms": 900
        }
       },
       "audio/mpeg": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/transcribe": {
   "post": {
    "operationId": "transcribe",
    "summary": "Speech to text ($0.01 USDC per call)",
    "description": "Speech to text: Whisper large-v3-turbo (fallback Whisper for files <= 3 MB) transcribes audio up to 10 MB in any common format. Body {audio_url (https, <=10 MB)} or {audio_base64 (<=4.5 MB raw because of the 6 MB body cap)} or raw audio/* bytes; optional language (ISO 639-1). Returns {text, language, duration_s, word_count, segments, vtt, model}. $0.01 USDC per file. Limits: audio <= 10 MB by URL, <= 4.5 MB inline (6 MB request cap); fetched in 8 s from a public https host. Models: @cf/openai/whisper-large-v3-turbo, @cf/openai/whisper.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.010000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "10000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "audio_url": {
          "type": "string",
          "format": "uri"
         },
         "audio_base64": {
          "type": "string"
         },
         "language": {
          "type": "string"
         }
        }
       },
       "example": {
        "audio_url": "https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg",
        "language": "en"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "text": "The examples are short recordings used to test audio playback.",
         "language": "en",
         "duration_s": 6.1,
         "word_count": 11,
         "segments": [
          {
           "start": 0,
           "end": 6.1,
           "text": "The examples are short recordings used to test audio playback."
          }
         ],
         "vtt": "WEBVTT\n\n00:00.000 --> 00:06.100\nThe examples are short recordings used to test audio playback.",
         "model": "@cf/openai/whisper-large-v3-turbo",
         "fallback": false,
         "took_ms": 2100
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/translate": {
   "post": {
    "operationId": "translate",
    "summary": "Translate ($0.002 USDC per call)",
    "description": "Translation: Meta M2M100 1.2B between 100 languages (fallback Llama 3.1 8B with a translation prompt). Body {text (<=5,000 chars), source_lang? (ISO 639-1, default en), target_lang (ISO 639-1)}. Returns {translation, source_lang, target_lang, model}. $0.002 USDC per call. Limits: text <= 5,000 characters; language codes ISO 639-1 (en, es, fr, de, ja, ...). Models: @cf/meta/m2m100-1.2b, @cf/meta/llama-3.1-8b-instruct-fp8.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.002000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "2000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "text",
         "target_lang"
        ],
        "properties": {
         "text": {
          "type": "string",
          "maxLength": 5000
         },
         "source_lang": {
          "type": "string",
          "default": "en"
         },
         "target_lang": {
          "type": "string"
         }
        }
       },
       "example": {
        "text": "The invoice is due in thirty days.",
        "source_lang": "en",
        "target_lang": "es"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "translation": "La factura vence en treinta días.",
         "source_lang": "en",
         "target_lang": "es",
         "model": "@cf/meta/m2m100-1.2b",
         "fallback": false,
         "took_ms": 400
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/summarize": {
   "post": {
    "operationId": "summarize",
    "summary": "Summarize ($0.002 USDC per call)",
    "description": "Summarization: Llama 3.1 8B instruct (fp8) with a summarization prompt; BART-large-CNN is no longer in the Workers AI catalog. Body {text (<=20,000 chars), max_words? (20-400, default 120)}. Returns {summary, max_words, input_chars, model}. $0.002 USDC per call. Limits: text 20 to 20,000 characters; max_words 20-400. Models: @cf/meta/llama-3.1-8b-instruct-fp8, @cf/meta/llama-3.2-3b-instruct.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.002000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "2000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "text"
        ],
        "properties": {
         "text": {
          "type": "string",
          "minLength": 20,
          "maxLength": 20000
         },
         "max_words": {
          "type": "integer",
          "minimum": 20,
          "maximum": 400,
          "default": 120
         }
        }
       },
       "example": {
        "text": "Cloudflare Workers AI runs machine learning models on Cloudflare's global network... (up to 20,000 characters)",
        "max_words": 60
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "summary": "Workers AI runs machine-learning models on Cloudflare's network, billed per use, with a free daily allowance.",
         "max_words": 60,
         "input_chars": 1840,
         "model": "@cf/meta/llama-3.1-8b-instruct-fp8",
         "fallback": false,
         "usage": {
          "prompt_tokens": 470,
          "completion_tokens": 26,
          "total_tokens": 496
         },
         "took_ms": 1300
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/embed": {
   "post": {
    "operationId": "embed",
    "summary": "Embeddings ($0.001 USDC per call)",
    "description": "Text embeddings: BAAI bge-m3, 1024 dimensions, multilingual, up to 32 texts of 2,000 characters per call (fallback bge-base-en-v1.5, 768 dims, English). Body {texts: [...]}. Returns {vectors, dims, count, model}. $0.001 USDC per call, not per text. Limits: 1-32 texts, each <= 2,000 characters. Models: @cf/baai/bge-m3, @cf/baai/bge-base-en-v1.5.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.001000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "1000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "texts"
        ],
        "properties": {
         "texts": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
           "type": "string",
           "maxLength": 2000
          }
         }
        }
       },
       "example": {
        "texts": [
         "pay-per-call image generation",
         "USDC settlement on Base"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "vectors": [
          [
           0.0123,
           -0.0456,
           "...1024 numbers"
          ],
          [
           0.0311,
           0.0021,
           "..."
          ]
         ],
         "dims": 1024,
         "count": 2,
         "model": "@cf/baai/bge-m3",
         "fallback": false,
         "took_ms": 120
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/chat": {
   "post": {
    "operationId": "chat",
    "summary": "Chat completions ($0.005 USDC per call)",
    "description": "OpenAI-style chat completion: Llama 3.1 8B instruct fp8 at $0.005 (model \"llama-3.1-8b\", default) or Llama 3.3 70B instruct fp8-fast at $0.02 (model \"llama-3.3-70b\" in the body or ?model=llama-3.3-70b; the 402 then asks for 20000). Body {messages (<=20, <=12,000 chars total), model?, max_tokens? (<=1024, default 256), temperature? (0-2)}. Returns {choices:[{message}], usage, model} and no stream. Limits: <= 20 messages, <= 12,000 characters in total; max_tokens <= 1024; roles system, user, assistant. Models: @cf/meta/llama-3.1-8b-instruct-fp8, @cf/meta/llama-3.3-70b-instruct-fp8-fast, @cf/meta/llama-3.2-3b-instruct.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "5000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "x-payment-info-variants": [
     {
      "when": "model = \"llama-3.3-70b\" (body or ?model=)",
      "price": {
       "mode": "fixed",
       "currency": "USD",
       "amount": "0.020000"
      },
      "protocols": [
       {
        "x402": {
         "version": 1,
         "scheme": "exact",
         "network": "eip155:8453",
         "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
         "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
         "amount_atomic": "20000",
         "facilitator": "https://facilitator.payai.network"
        }
       }
      ]
     }
    ],
    "parameters": [
     {
      "name": "model",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "llama-3.1-8b",
        "llama-3.3-70b"
       ]
      },
      "description": "model tier; llama-3.3-70b costs $0.02"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "messages"
        ],
        "properties": {
         "messages": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
           "type": "object",
           "required": [
            "role",
            "content"
           ],
           "properties": {
            "role": {
             "type": "string",
             "enum": [
              "system",
              "user",
              "assistant"
             ]
            },
            "content": {
             "type": "string"
            }
           }
          }
         },
         "model": {
          "type": "string",
          "enum": [
           "llama-3.1-8b",
           "llama-3.3-70b",
           "@cf/meta/llama-3.1-8b-instruct-fp8",
           "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
          ],
          "default": "llama-3.1-8b"
         },
         "max_tokens": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1024,
          "default": 256
         },
         "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 2,
          "default": 0.7
         }
        }
       },
       "example": {
        "model": "llama-3.1-8b",
        "messages": [
         {
          "role": "user",
          "content": "Give me three names for a lighthouse-keeping robot."
         }
        ],
        "max_tokens": 120
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "id": "chatcmpl-8f1c...",
         "object": "chat.completion",
         "created": 1790000000,
         "model": "@cf/meta/llama-3.1-8b-instruct-fp8",
         "choices": [
          {
           "index": 0,
           "message": {
            "role": "assistant",
            "content": "Beacon, Fresnel, and Keeper-9."
           },
           "finish_reason": "stop"
          }
         ],
         "usage": {
          "prompt_tokens": 21,
          "completion_tokens": 12,
          "total_tokens": 33
         },
         "took_ms": 700
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/classify": {
   "post": {
    "operationId": "classify",
    "summary": "Classify text ($0.001 USDC per call)",
    "description": "Text classification: sentiment (POSITIVE/NEGATIVE with scores) from DistilBERT SST-2, or zero-shot into your own labels (2-10) with Llama 3.1 8B when {labels} is sent. Body {text (<=5,000 chars; <=2,000 for zero-shot), labels?}. Returns {label, scores|confidence, method, model}. $0.001 USDC per call. Limits: text <= 5,000 characters (<= 2,000 with labels); 2-10 labels of <= 60 characters. Models: @cf/huggingface/distilbert-sst-2-int8, @cf/meta/llama-3.1-8b-instruct-fp8.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.001000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "1000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "text"
        ],
        "properties": {
         "text": {
          "type": "string",
          "maxLength": 5000
         },
         "labels": {
          "type": "array",
          "minItems": 2,
          "maxItems": 10,
          "items": {
           "type": "string",
           "maxLength": 60
          }
         }
        }
       },
       "example": {
        "text": "The checkout kept timing out and support never answered."
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "label": "NEGATIVE",
         "scores": {
          "POSITIVE": 0.0009,
          "NEGATIVE": 0.9991
         },
         "method": "SST-2 sentiment (POSITIVE/NEGATIVE)",
         "model": "@cf/huggingface/distilbert-sst-2-int8",
         "took_ms": 60
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/ocr": {
   "post": {
    "operationId": "ocr",
    "summary": "Read text in an image ($0.005 USDC per call)",
    "description": "Image to text: LLaVA 1.5 7B (fallback Llama 3.2 11B Vision) reads the text visible in an image. It is a vision-language model, not a dedicated OCR engine, so expect mistakes on dense pages or tiny print; good for signs, labels, screenshots and short documents. Body {image_url (<=5 MB)} or {image_base64} or raw image/* bytes. Returns {text, method, model}. $0.005 USDC per image. Limits: image <= 5 MB; image_url fetched in 8 s from a public https host. Models: @cf/llava-hf/llava-1.5-7b-hf, @cf/meta/llama-3.2-11b-vision-instruct.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.005000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "5000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "image_url": {
          "type": "string",
          "format": "uri"
         },
         "image_base64": {
          "type": "string"
         }
        }
       },
       "example": {
        "image_url": "https://upload.wikimedia.org/wikipedia/commons/2/25/Stop_sign_MUTCD.svg.png"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "text": "STOP",
         "method": "vision-language model reading the image; not a dedicated OCR engine",
         "model": "@cf/llava-hf/llava-1.5-7b-hf",
         "fallback": false,
         "image_bytes": 20411,
         "source": "url",
         "took_ms": 1700
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/detect-language": {
   "post": {
    "operationId": "detect_language",
    "summary": "Detect language ($0.001 USDC per call)",
    "description": "Language detection by a heuristic (Unicode script ranges plus stopword frequencies for 20 Latin-script languages); no model runs, sub-millisecond, reliable from about 20 characters of prose. Body {text (<=20,000 chars)}. Returns {language (ISO 639-1 or 'und'), name, script, confidence, method}. $0.001 USDC per call. Limits: text <= 20,000 characters; 'und' when nothing matches. Models: none (heuristic).",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.001000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "1000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "text"
        ],
        "properties": {
         "text": {
          "type": "string",
          "maxLength": 20000
         }
        }
       },
       "example": {
        "text": "La factura vence en treinta días y el pago se realiza por transferencia."
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "language": "es",
         "name": "Spanish",
         "script": "latin",
         "confidence": 0.86,
         "method": "heuristic: Unicode script ranges and stopword frequencies (20 Latin-script languages); no model",
         "chars": 71,
         "took_ms": 0
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/batch": {
   "post": {
    "operationId": "batch",
    "summary": "Batch of 100 ($1.00 USDC per call)",
    "description": "One request, up to 100 items across embed, translate, summarize and classify with the same limits as the single routes (total text <= 500,000 characters); items run 4 at a time and each returns its own result or error. Body {items: [{op: 'embed'|'translate'|'summarize'|'classify', ...fields of that route}]}. Returns {results, count, ok_count}. $1.00 USDC per batch whatever the item count; a batch whose items all fail can be replayed free within 10 minutes. Limits: 1-100 items; ops embed (<=32 texts of 2,000 chars), translate (<=5,000 chars), summarize (<=20,000 chars), classify (<=5,000 chars); total text <= 500,000 characters; a single bad item fails the whole batch before payment. Models: @cf/baai/bge-m3, @cf/meta/m2m100-1.2b, @cf/meta/llama-3.1-8b-instruct-fp8, @cf/huggingface/distilbert-sst-2-int8.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "1.000000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "1000000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "items"
        ],
        "properties": {
         "items": {
          "type": "array",
          "minItems": 1,
          "maxItems": 100,
          "items": {
           "type": "object",
           "required": [
            "op"
           ],
           "properties": {
            "op": {
             "type": "string",
             "enum": [
              "embed",
              "translate",
              "summarize",
              "classify"
             ]
            },
            "text": {
             "type": "string"
            },
            "texts": {
             "type": "array",
             "items": {
              "type": "string"
             }
            },
            "source_lang": {
             "type": "string"
            },
            "target_lang": {
             "type": "string"
            },
            "max_words": {
             "type": "integer"
            },
            "labels": {
             "type": "array",
             "items": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       },
       "example": {
        "items": [
         {
          "op": "translate",
          "text": "Where is the station?",
          "target_lang": "de"
         },
         {
          "op": "classify",
          "text": "Loved it, fast and simple."
         },
         {
          "op": "embed",
          "texts": [
           "one",
           "two"
          ]
         }
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "count": 3,
         "ok_count": 3,
         "failed_count": 0,
         "results": [
          {
           "index": 0,
           "op": "translate",
           "ok": true,
           "result": {
            "translation": "Wo ist der Bahnhof?",
            "source_lang": "en",
            "target_lang": "de",
            "model": "@cf/meta/m2m100-1.2b"
           }
          },
          {
           "index": 1,
           "op": "classify",
           "ok": true,
           "result": {
            "label": "POSITIVE",
            "scores": {
             "POSITIVE": 0.9994,
             "NEGATIVE": 0.0006
            },
            "model": "@cf/huggingface/distilbert-sst-2-int8"
           }
          },
          {
           "index": 2,
           "op": "embed",
           "ok": true,
           "result": {
            "dims": 1024,
            "count": 2,
            "vectors": [
             "..."
            ],
            "model": "@cf/baai/bge-m3"
           }
          }
         ],
         "took_ms": 2600
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/image-set": {
   "post": {
    "operationId": "image_set",
    "summary": "Image set of 20 ($5.00 USDC per call)",
    "description": "Twenty 1024x1024 JPEGs from a list of 1-20 prompts (prompts are cycled to fill 20 slots), FLUX.1 [schnell] at 1-4 steps each: schnell-grade quality, no upscaling, no SDXL fallback, seeds seed+i. Body {prompts: [...] (<=1,000 chars each), steps? (1-4, default 4), seed?}. Returns {images: [{index, prompt_index, seed, image_base64, mime}], ok_count, model}. $5.00 USDC per set; when 10 or more slots fail the call answers 502 and can be replayed free within 10 minutes. Limits: 1-20 prompts of <= 1,000 characters; steps 1-4; always 20 images (prompts cycle); response about 2-4 MB of base64. Models: @cf/black-forest-labs/flux-1-schnell.",
    "tags": [
     "paid"
    ],
    "x-payment-info": {
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "5.000000"
     },
     "protocols": [
      {
       "x402": {
        "version": 1,
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
        "amount_atomic": "5000000",
        "facilitator": "https://facilitator.payai.network"
       }
      }
     ]
    },
    "parameters": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "prompts"
        ],
        "properties": {
         "prompts": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
           "type": "string",
           "maxLength": 1000
          }
         },
         "steps": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4,
          "default": 4
         },
         "seed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4294967295
         }
        }
       },
       "example": {
        "prompts": [
         "a red lighthouse at dawn, fog",
         "a blue lighthouse at noon, clear sky",
         "a white lighthouse at dusk, storm"
        ],
        "steps": 4,
        "seed": 100
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result",
      "headers": {
       "PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        },
        "description": "base64 settlement receipt {success, transaction, network, payer}"
       },
       "X-PAYMENT-RESPONSE": {
        "schema": {
         "type": "string"
        }
       },
       "X-Request-Id": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        },
        "example": {
         "count": 20,
         "ok_count": 20,
         "failed_count": 0,
         "model": "@cf/black-forest-labs/flux-1-schnell",
         "steps": 4,
         "quality": "schnell-grade: FLUX.1 [schnell], 1024x1024 JPEG, <= 4 steps, no upscaling",
         "images": [
          {
           "index": 0,
           "prompt_index": 0,
           "seed": 100,
           "mime": "image/jpeg",
           "image_base64": "/9j/4AAQ...(JPEG, base64)"
          },
          {
           "index": 1,
           "prompt_index": 1,
           "seed": 101,
           "mime": "image/jpeg",
           "image_base64": "..."
          }
         ],
         "took_ms": 21000
        }
       }
      }
     },
     "400": {
      "description": "Malformed input or refused content; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v1 requirements in the JSON body (accepts[0] is Base USDC, exact scheme) and the v2 envelope in the PAYMENT-REQUIRED header.",
      "headers": {
       "PAYMENT-REQUIRED": {
        "schema": {
         "type": "string"
        },
        "description": "base64 x402 v2 requirements"
       },
       "WWW-Authenticate": {
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PaymentRequired"
        }
       }
      }
     },
     "409": {
      "description": "Payment nonce already used",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Body or input over its limit; nothing settled",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 20 unpaid requests per minute from this address",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "502": {
      "description": "Model failed after settlement; replay once with the same X-PAYMENT within 10 minutes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/samples": {
   "get": {
    "operationId": "samples",
    "summary": "index of free sample requests and responses (JSON)",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/live.json": {
   "get": {
    "operationId": "live_json",
    "summary": "per-route counters: 402s served, paid calls, successes, failures per day (JSON)",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/health": {
   "get": {
    "operationId": "health",
    "summary": "service health (JSON)",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/openapi.json": {
   "get": {
    "operationId": "openapi_json",
    "summary": "OpenAPI 3.1 with x-payment-info on each paid operation",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/.well-known/x402": {
   "get": {
    "operationId": "well_known_x402",
    "summary": "x402 manifest: every paid route with the same prices as the challenges",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/.well-known/agent-card.json": {
   "get": {
    "operationId": "well_known_agent_card_json",
    "summary": "A2A agent card, one skill per route",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/llms.txt": {
   "get": {
    "operationId": "llms_txt",
    "summary": "this list for language models",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/mcp": {
   "post": {
    "operationId": "mcp",
    "summary": "MCP Streamable HTTP endpoint (JSON-RPC 2.0 over POST): tools/list, tools/call returns payment instructions",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/a2a": {
   "post": {
    "operationId": "a2a",
    "summary": "A2A JSON-RPC 2.0 endpoint (POST; protocol 0.3.0): message/send, tasks/get, tasks/cancel; free skills complete at once, paid skills answer input-required with the same x402 terms as the HTTP 402 (a2a-x402 v0.1)",
    "tags": [
     "free"
    ],
    "security": [],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     }
    }
   }
  },
  "/samples/{route}.json": {
   "get": {
    "operationId": "sample",
    "summary": "one sample request and response for a paid route",
    "tags": [
     "free"
    ],
    "security": [],
    "parameters": [
     {
      "name": "route",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "image",
        "caption",
        "speech",
        "transcribe",
        "translate",
        "summarize",
        "embed",
        "chat",
        "classify",
        "ocr",
        "detect-language",
        "batch",
        "image-set"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Sample",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true
        }
       }
      }
     },
     "404": {
      "description": "Unknown route",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Error": {
    "type": "object",
    "required": [
     "error",
     "code",
     "status",
     "request_id"
    ],
    "properties": {
     "error": {
      "type": "string",
      "description": "plain message"
     },
     "code": {
      "type": "string",
      "description": "snake_case machine code, e.g. model_failed, content_refused, body_too_large, invalid_json, rate_limited"
     },
     "status": {
      "type": "integer"
     },
     "hint": {
      "type": "string"
     },
     "docs": {
      "type": "string"
     },
     "request_id": {
      "type": "string"
     }
    }
   },
   "PaymentRequired": {
    "type": "object",
    "properties": {
     "x402Version": {
      "type": "integer"
     },
     "error": {
      "type": "string"
     },
     "accepts": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "scheme": {
         "type": "string"
        },
        "network": {
         "type": "string"
        },
        "maxAmountRequired": {
         "type": "string"
        },
        "resource": {
         "type": "string"
        },
        "payTo": {
         "type": "string"
        },
        "asset": {
         "type": "string"
        },
        "maxTimeoutSeconds": {
         "type": "integer"
        }
       }
      }
     },
     "resource": {
      "type": "object"
     },
     "extensions": {
      "type": "object"
     }
    }
   }
  }
 }
}