{
  "openapi": "3.1.0",
  "info": {
    "title": "x402-gateway",
    "version": "1.0.0",
    "description": "Pay-per-call edge gateway on x402 v2 / Base USDC. Use /.well-known/x402 for discovery and PAYMENT-SIGNATURE for paid calls.",
    "contact": {
      "name": "Gagandeep Singh"
    }
  },
  "servers": [
    {
      "url": "https://x402-gateway.grokrepay.workers.dev"
    }
  ],
  "paths": {
    "/verify-citation": {
      "post": {
        "operationId": "verify_citation",
        "summary": "Web-page citation verifier",
        "description": "Fetch a public web page and verify whether it supports a quoted claim using Workers AI.",
        "tags": [
          "paid"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            {
              "x402": {
                "version": 2
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "claim"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https URL"
                  },
                  "claim": {
                    "type": "string",
                    "description": "quoted claim to verify"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful tool response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (x402 v2: PAYMENT-REQUIRED header, USDC on Base)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Resource unavailable; not charged"
          }
        }
      }
    },
    "/extract-json": {
      "post": {
        "operationId": "extract_json",
        "summary": "Structured JSON extractor",
        "description": "Extract structured JSON from a URL or text against a provided JSON schema using Workers AI.",
        "tags": [
          "paid"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.010000"
          },
          "protocols": [
            {
              "x402": {
                "version": 2
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "schema"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https URL to extract from"
                  },
                  "text": {
                    "type": "string",
                    "description": "raw text to extract from"
                  },
                  "schema": {
                    "type": "object",
                    "description": "JSON schema to match"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful tool response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (x402 v2: PAYMENT-REQUIRED header, USDC on Base)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Resource unavailable; not charged"
          }
        }
      }
    },
    "/crypto-signal-audit": {
      "post": {
        "operationId": "crypto_signal_audit",
        "summary": "Crypto signal sanity audit",
        "description": "On-chain/public-data sanity audit of a token or contract claim on Base.",
        "tags": [
          "paid"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.020000"
          },
          "protocols": [
            {
              "x402": {
                "version": 2
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token",
                  "claim"
                ],
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "token or contract address on Base"
                  },
                  "claim": {
                    "type": "string",
                    "description": "claim to sanity-check"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful tool response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (x402 v2: PAYMENT-REQUIRED header, USDC on Base)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Resource unavailable; not charged"
          }
        }
      }
    },
    "/prediction-mispricing": {
      "post": {
        "operationId": "prediction_mispricing",
        "summary": "Prediction market mispricing feed",
        "description": "Compare Polymarket prices with recent public news headlines and return markets where the price appears to have moved less than the news suggests.",
        "tags": [
          "paid"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.050000"
          },
          "protocols": [
            {
              "x402": {
                "version": 2
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "max_markets": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30,
                    "default": 12,
                    "description": "Number of Polymarket markets to analyze"
                  },
                  "news_feeds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "description": "Optional list of https RSS feed URLs"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful tool response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (x402 v2: PAYMENT-REQUIRED header, USDC on Base)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Resource unavailable; not charged"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp_proxy",
        "summary": "MCP streamable-HTTP proxy",
        "description": "MCP streamable-HTTP proxy exposing verify-citation, extract-json and crypto-signal-audit. Free for initialize/tools-list/ping; paid per tools/call.",
        "tags": [
          "mcp"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {},
                  "method": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result"
          },
          "202": {
            "description": "Notification accepted"
          },
          "402": {
            "description": "Payment Required for tools/call"
          }
        }
      }
    },
    "/.well-known/x402": {
      "get": {
        "operationId": "x402Discovery",
        "security": [],
        "summary": "x402 discovery document",
        "responses": {
          "200": {
            "description": "Discovery document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "openApi",
        "security": [],
        "summary": "OpenAPI document",
        "responses": {
          "200": {
            "description": "OpenAPI document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "llmsTxt",
        "security": [],
        "summary": "llms.txt",
        "responses": {
          "200": {
            "description": "llms.txt",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/": {
      "get": {
        "operationId": "index",
        "security": [],
        "summary": "Landing page",
        "responses": {
          "200": {
            "description": "HTML landing page",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}