{
  "openapi": "3.1.0",
  "info": {
    "title": "FrostSkyNet Data Tools",
    "version": "0.1.0-preview",
    "description": "preview; mainnet settlement and public indexing unverified"
  },
  "servers": [
    {
      "url": "https://route-a-worker.frostskynet-api.workers.dev"
    }
  ],
  "paths": {
    "/clean": {
      "post": {
        "operationId": "frostskynet_clean",
        "summary": "Converts text, JSON or JSONL to cleaned JSONL using fixed rules. Removes empty, short and duplicate rows; can repair some encoding issues. No AI or CSV parsing.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "input": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Nonempty input text. Limit applies to the entire UTF-8 JSON request body including options and escaping, not just this string."
                  },
                  "options": {
                    "type": "object",
                    "description": "Optional settings.",
                    "properties": {
                      "minChars": {
                        "type": "integer",
                        "description": "Drop rows shorter than this (1-1000, default 3).",
                        "minimum": 1,
                        "maximum": 1000
                      },
                      "keepDuplicates": {
                        "type": "boolean",
                        "description": "Keep duplicate rows (default false)."
                      }
                    }
                  }
                },
                "required": [
                  "input"
                ],
                "type": "object"
              },
              "example": {
                "input": "Hello world.\n\nHello world.\nAnother useful line.",
                "options": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Processed output after verified payment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "output",
                    "stats"
                  ],
                  "properties": {
                    "output": {
                      "type": "string"
                    },
                    "stats": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "output": "{\"text\": \"Hello world.\"}\n{\"text\": \"Another useful line.\"}\n",
                  "stats": {
                    "inputFormat": "text",
                    "rowsIn": 4,
                    "rowsOut": 2,
                    "droppedEmpty": 1,
                    "droppedShort": 0,
                    "droppedDuplicates": 1,
                    "unparseable": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options"
          },
          "402": {
            "description": "Payment required; inspect PAYMENT-REQUIRED before signing",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "Base64-encoded x402 v2 requirements"
              }
            }
          },
          "413": {
            "description": "Complete request body exceeds limit; rejected before payment"
          },
          "429": {
            "description": "Too many requests if rate limiting is enabled; honor Retry-After"
          },
          "500": {
            "description": "Service error; investigate settlement before paying again"
          },
          "503": {
            "description": "Temporarily unavailable or configuration failure"
          }
        },
        "x-payment": {
          "scheme": "exact",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x3a1121e787586a504fF74FC53E3AcEE19faDE698",
          "priceUsdc": "0.005"
        },
        "x-max-request-body-bytes": 51200
      }
    },
    "/judge": {
      "post": {
        "operationId": "frostskynet_judge",
        "summary": "Scores JSONL rows using fixed rules and adds _quality. Detects some PII and bad-word patterns; optional redaction and score filtering. Detection is incomplete and can produce false positives. No AI.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "input": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Nonempty input text. Limit applies to the entire UTF-8 JSON request body including options and escaping, not just this string."
                  },
                  "options": {
                    "type": "object",
                    "description": "Optional settings.",
                    "properties": {
                      "stripPii": {
                        "type": "boolean",
                        "description": "Redact PII in text (default false, flag only)."
                      },
                      "stripBadWords": {
                        "type": "boolean",
                        "description": "Mask bad language with **** (default false, flag only)."
                      },
                      "filter": {
                        "type": "boolean",
                        "description": "Drop rows below minScore (default false, keep all)."
                      },
                      "minScore": {
                        "type": "integer",
                        "description": "Score threshold for filter (0-100, default 70).",
                        "minimum": 0,
                        "maximum": 100
                      }
                    }
                  }
                },
                "required": [
                  "input"
                ],
                "type": "object"
              },
              "example": {
                "input": "{\"text\":\"Contact jane@example.com for details.\"}\n{\"text\":\"This is a useful sample sentence.\"}\n",
                "options": {
                  "stripPii": true
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Processed output after verified payment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "output",
                    "stats"
                  ],
                  "properties": {
                    "output": {
                      "type": "string"
                    },
                    "stats": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "output": "{\"text\": \"Contact [EMAIL] for details.\", \"_quality\": {\"score\": 95, \"issues\": [\"pii_redacted\"], \"pii_types\": {\"email\": 1}, \"llm_score\": null}}\n{\"text\": \"This is a useful sample sentence.\", \"_quality\": {\"score\": 100, \"issues\": [], \"pii_types\": {}, \"llm_score\": null}}\n",
                  "stats": {
                    "rowsIn": 2,
                    "rowsOut": 2,
                    "averageScore": 98,
                    "issueCounts": {
                      "pii_redacted": 1
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options"
          },
          "402": {
            "description": "Payment required; inspect PAYMENT-REQUIRED before signing",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "Base64-encoded x402 v2 requirements"
              }
            }
          },
          "413": {
            "description": "Complete request body exceeds limit; rejected before payment"
          },
          "429": {
            "description": "Too many requests if rate limiting is enabled; honor Retry-After"
          },
          "500": {
            "description": "Service error; investigate settlement before paying again"
          },
          "503": {
            "description": "Temporarily unavailable or configuration failure"
          }
        },
        "x-payment": {
          "scheme": "exact",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x3a1121e787586a504fF74FC53E3AcEE19faDE698",
          "priceUsdc": "0.01"
        },
        "x-max-request-body-bytes": 10240
      }
    },
    "/format": {
      "post": {
        "operationId": "frostskynet_format",
        "summary": "Converts JSONL rows to JSONL, chat training examples or Markdown. Returns the serialized result as an output string with stats. No AI.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "input": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Nonempty input text. Limit applies to the entire UTF-8 JSON request body including options and escaping, not just this string."
                  },
                  "options": {
                    "type": "object",
                    "description": "Optional settings.",
                    "properties": {
                      "format": {
                        "type": "string",
                        "enum": [
                          "jsonl",
                          "chat",
                          "markdown",
                          "md"
                        ],
                        "description": "Output layout. 'md' is alias for 'markdown'. Default 'jsonl'."
                      },
                      "system": {
                        "type": "string",
                        "description": "System prompt for chat mode (max 2000 chars).",
                        "maxLength": 2000
                      },
                      "keepScores": {
                        "type": "boolean",
                        "description": "Keep _quality fields in jsonl/chat output (default false)."
                      }
                    }
                  }
                },
                "required": [
                  "input"
                ],
                "type": "object"
              },
              "example": {
                "input": "{\"question\":\"What is JSONL?\",\"answer\":\"One JSON value per line.\"}\n",
                "options": {
                  "format": "chat"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Processed output after verified payment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "output",
                    "stats"
                  ],
                  "properties": {
                    "output": {
                      "type": "string"
                    },
                    "stats": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "output": "{\"messages\": [{\"role\": \"user\", \"content\": \"What is JSONL?\"}, {\"role\": \"assistant\", \"content\": \"One JSON value per line.\"}]}\n",
                  "stats": {
                    "format": "chat",
                    "rowsIn": 1,
                    "rowsOut": 1,
                    "skipped": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or options"
          },
          "402": {
            "description": "Payment required; inspect PAYMENT-REQUIRED before signing",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "Base64-encoded x402 v2 requirements"
              }
            }
          },
          "413": {
            "description": "Complete request body exceeds limit; rejected before payment"
          },
          "429": {
            "description": "Too many requests if rate limiting is enabled; honor Retry-After"
          },
          "500": {
            "description": "Service error; investigate settlement before paying again"
          },
          "503": {
            "description": "Temporarily unavailable or configuration failure"
          }
        },
        "x-payment": {
          "scheme": "exact",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x3a1121e787586a504fF74FC53E3AcEE19faDE698",
          "priceUsdc": "0.005"
        },
        "x-max-request-body-bytes": 51200
      }
    }
  }
}
