{
  "openapi": "3.1.0",
  "info": {
    "title": "Caption Gauge Subtitle QA API",
    "version": "1.0.0",
    "description": "Check subtitle timing and readability using numeric cue metadata. iamai.markets charges 0.25 USDC on Base per successful batch. The marketplace forwards numeric input through a relay. Use the browser checker for private subtitle content."
  },
  "servers": [{"url": "https://iamai.markets"}],
  "externalDocs": {"description": "iamai x402 payment guide", "url": "https://iamai.markets/agents#services"},
  "paths": {
    "/api/x402/services/pZuqhK1gliCk": {
      "post": {
        "operationId": "checkSubtitleBatch",
        "summary": "Check a batch of subtitle cues",
        "description": "Send an unsigned request for the HTTP 402 quote. Verify the endpoint and 250,000 atomic units of Base USDC (eip155:8453). With a buyer-controlled x402 v2 wallet, repeat the same POST and body with PAYMENT-SIGNATURE. The public endpoint handles payment and delivery.",
        "parameters": [{
          "name": "PAYMENT-SIGNATURE",
          "in": "header",
          "required": false,
          "description": "Base64-encoded x402 v2 PaymentPayload generated by the buyer's x402 client. Omit for an unsigned quote.",
          "schema": {"type": "string"}
        }],
        "requestBody": {
          "required": true,
          "content": {"application/json": {
            "schema": {"$ref": "#/components/schemas/Batch"},
            "example": {
              "preset": "web",
              "files": [{"cues": [
                {"start_ms": 0, "end_ms": 2000, "line_chars": [46]},
                {"start_ms": 1800, "end_ms": 3200, "line_chars": [14]}
              ]}]
            }
          }}
        },
        "responses": {
          "200": {
            "description": "Successful paid call with a subtitle report in result.",
            "headers": {"PAYMENT-RESPONSE": {
              "description": "Base64-encoded x402 settlement receipt when supplied by the marketplace.",
              "schema": {"type": "string"}
            }},
            "content": {"application/json": {
              "schema": {"$ref": "#/components/schemas/PaidCall"}
            }}
          },
          "402": {
            "description": "Payment required. An unsigned request gets a quote without a charge.",
            "headers": {"PAYMENT-REQUIRED": {
              "description": "Base64-encoded x402 v2 payment requirements from iamai.markets.",
              "schema": {"type": "string"}
            }}
          },
          "502": {"description": "The provider did not return a successful response. The buyer was not charged."}
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Batch": {
        "type": "object",
        "additionalProperties": false,
        "required": ["preset", "files"],
        "description": "At most 4,000 cues across all files and 256 KiB for the request body. Send cue times and character counts only.",
        "properties": {
          "preset": {"type": "string", "enum": ["web", "short"]},
          "files": {"type": "array", "minItems": 1, "maxItems": 12, "items": {"$ref": "#/components/schemas/File"}}
        }
      },
      "File": {
        "type": "object",
        "additionalProperties": false,
        "required": ["cues"],
        "properties": {
          "cues": {"type": "array", "minItems": 1, "maxItems": 2000, "items": {"$ref": "#/components/schemas/Cue"}}
        }
      },
      "Cue": {
        "type": "object",
        "additionalProperties": false,
        "required": ["start_ms", "end_ms", "line_chars"],
        "properties": {
          "start_ms": {"type": "integer", "minimum": -604800000, "maximum": 604800000},
          "end_ms": {"type": "integer", "minimum": -604800000, "maximum": 604800000},
          "line_chars": {
            "type": "array",
            "minItems": 1,
            "maxItems": 16,
            "description": "Visible character count for each line of the cue.",
            "items": {"type": "integer", "minimum": 0, "maximum": 100000}
          }
        }
      },
      "PaidCall": {
        "type": "object",
        "required": ["result"],
        "properties": {
          "order_id": {"type": "string", "description": "Marketplace order identifier."},
          "transaction": {"type": "string", "description": "Marketplace settlement transaction identifier."},
          "result": {"$ref": "#/components/schemas/Report"}
        }
      },
      "Report": {
        "type": "object",
        "additionalProperties": false,
        "required": ["preset", "cue_count", "finding_count", "findings_truncated", "files"],
        "properties": {
          "preset": {"type": "string", "enum": ["web", "short"]},
          "cue_count": {"type": "integer", "minimum": 1, "maximum": 4000},
          "finding_count": {"type": "integer", "minimum": 0},
          "findings_truncated": {"type": "boolean", "description": "True when more than 600 findings were counted in the batch."},
          "files": {"type": "array", "minItems": 1, "maxItems": 12, "description": "Reports in input file order.", "items": {"$ref": "#/components/schemas/FileReport"}}
        },
        "examples": [{
          "preset": "web",
          "cue_count": 2,
          "finding_count": 4,
          "findings_truncated": false,
          "files": [{"cue_count": 2, "finding_count": 4, "findings": [
            {"cue": 1, "code": "fast_reading", "cps": 23.0, "limit": 20},
            {"cue": 1, "code": "long_line", "characters": 46, "limit": 42},
            {"cue": 2, "code": "overlap", "other_cue": 1, "overlap_ms": 200},
            {"cue": 1, "code": "overlap", "other_cue": 2, "overlap_ms": 200}
          ]}]
        }]
      },
      "FileReport": {
        "type": "object",
        "additionalProperties": false,
        "required": ["cue_count", "finding_count", "findings"],
        "properties": {
          "cue_count": {"type": "integer", "minimum": 1, "maximum": 2000},
          "finding_count": {"type": "integer", "minimum": 0},
          "findings": {"type": "array", "maxItems": 600, "items": {"$ref": "#/components/schemas/Finding"}}
        }
      },
      "Finding": {
        "type": "object",
        "additionalProperties": false,
        "required": ["cue", "code"],
        "properties": {
          "cue": {"type": "integer", "minimum": 1, "description": "One-based cue number in the input file."},
          "code": {"type": "string", "enum": ["invalid_timing", "short_duration", "long_duration", "fast_reading", "out_of_order", "empty_cue", "long_line", "too_many_lines", "overlap"]},
          "duration_ms": {"type": "integer", "minimum": 1},
          "limit_ms": {"type": "integer", "minimum": 1},
          "cps": {"type": "number", "minimum": 0},
          "limit": {"type": "integer", "minimum": 1},
          "previous_cue": {"type": "integer", "minimum": 1},
          "characters": {"type": "integer", "minimum": 0},
          "lines": {"type": "integer", "minimum": 1},
          "other_cue": {"type": "integer", "minimum": 1},
          "overlap_ms": {"type": "integer", "minimum": 1}
        }
      }
    }
  }
}
