{
  "openapi": "3.1.0",
  "info": {
    "title": "Parallel API Gateway",
    "version": "1.0.0",
    "description": "Parallel Web Systems APIs (Search, Extract, Task) payment-gated via MPP/Tempo (pathUSD). Clients pay with HTTP 402 challenges using the mppx SDK.",
    "x-guidance": "Paid endpoints (POST /api/search, /api/extract, /api/task) require MPP payment via HTTP 402. Create an account with `npx mppx account create`, fund it with pathUSD, then call any paid endpoint — the mppx CLI or SDK handles the challenge automatically. Poll task status for free at GET /api/task/{runId}. Check wallet balances for free at GET /api/wallet/balance/{address}."
  },
  "x-service-info": {
    "categories": [
      "ai",
      "search",
      "data-extraction"
    ],
    "docs": {
      "homepage": "https://parallelmpp.dev",
      "apiReference": "https://parallelmpp.dev/api",
      "llms": "https://parallelmpp.dev/llms.txt"
    }
  },
  "paths": {
    "/api/search": {
      "post": {
        "summary": "Search the web via Parallel Web Systems",
        "description": "Runs a Parallel Web Systems search. Use `mode: \"one-shot\"` for comprehensive results or `mode: \"fast\"` for lower latency.",
        "x-payment-info": {
          "amount": "10000",
          "currency": "0x20c000000000000000000000b9537d11c60e8b50",
          "description": "Web search — $0.01 per request",
          "intent": "charge",
          "method": "tempo"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "Search query (shorthand for objective)"
                  },
                  "objective": {
                    "type": "string",
                    "description": "Search objective"
                  },
                  "search_queries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Explicit search queries"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "one-shot",
                      "fast"
                    ],
                    "description": "Search mode: one-shot (comprehensive) or fast (lower latency)"
                  }
                }
              },
              "examples": {
                "simple": {
                  "summary": "Simple query",
                  "value": {
                    "query": "AI funding 2026",
                    "mode": "one-shot"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search results"
          },
          "400": {
            "description": "Missing or invalid request body"
          },
          "402": {
            "description": "Payment Required — use mppx to pay the Tempo challenge"
          },
          "429": {
            "description": "Rate limit exceeded (60 req/min)"
          }
        }
      }
    },
    "/api/extract": {
      "post": {
        "summary": "Extract content from URLs via Parallel Web Systems",
        "description": "Scrapes and extracts content from one or more URLs. Priced at $0.01 per URL (minimum $0.01).",
        "x-payment-info": {
          "amount": "10000",
          "currency": "0x20c000000000000000000000b9537d11c60e8b50",
          "description": "URL extraction — $0.01 per URL",
          "intent": "charge",
          "method": "tempo"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "urls"
                ],
                "properties": {
                  "urls": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "description": "URLs to extract content from"
                  },
                  "objective": {
                    "type": "string",
                    "description": "Optional extraction objective to guide content selection"
                  }
                }
              },
              "examples": {
                "single": {
                  "summary": "Single URL",
                  "value": {
                    "urls": [
                      "https://example.com"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extracted content"
          },
          "400": {
            "description": "Missing or invalid urls"
          },
          "402": {
            "description": "Payment Required — use mppx to pay the Tempo challenge"
          },
          "429": {
            "description": "Rate limit exceeded (60 req/min)"
          }
        }
      }
    },
    "/api/task": {
      "post": {
        "summary": "Run an async AI task via Parallel Web Systems",
        "description": "Starts an async Parallel Web Systems task. Returns a `run_id` — poll `GET /api/task/{runId}` until complete. Pricing: ultra $0.30, pro $0.10.",
        "x-payment-info": {
          "amount": "100000",
          "currency": "0x20c000000000000000000000b9537d11c60e8b50",
          "description": "AI task — $0.10 (pro) / $0.30 (ultra)",
          "intent": "charge",
          "method": "tempo"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "processor"
                ],
                "properties": {
                  "input": {
                    "type": "string",
                    "description": "Task input (or use query)"
                  },
                  "query": {
                    "type": "string",
                    "description": "Task query (shorthand for input)"
                  },
                  "processor": {
                    "type": "string",
                    "enum": [
                      "ultra",
                      "pro"
                    ],
                    "description": "Task tier: ultra ($0.30) or pro ($0.10)"
                  }
                }
              },
              "examples": {
                "ultra": {
                  "summary": "Ultra task",
                  "value": {
                    "input": "Brief HVAC market overview USA",
                    "processor": "ultra"
                  }
                },
                "pro": {
                  "summary": "Pro task",
                  "value": {
                    "input": "Summary of recent AI funding rounds",
                    "processor": "pro"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created — contains `run_id` and `poll_url`"
          },
          "400": {
            "description": "Missing input/query or processor"
          },
          "402": {
            "description": "Payment Required — use mppx to pay the Tempo challenge"
          },
          "429": {
            "description": "Rate limit exceeded (60 req/min)"
          }
        }
      }
    },
    "/api/task/{runId}": {
      "get": {
        "summary": "Poll task status (free)",
        "description": "Check the status of an async task. Returns result when status is \"completed\".",
        "x-payment-info": {
          "authMode": "none"
        },
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Task run ID (e.g. trun_xxxxx)"
          }
        ],
        "responses": {
          "200": {
            "description": "Task status and result (when completed)"
          },
          "500": {
            "description": "Error fetching task"
          }
        }
      }
    },
    "/api/wallet/balance/{address}": {
      "get": {
        "summary": "Check pathUSD balance (free)",
        "description": "Returns the pathUSD balance for a Tempo address.",
        "x-payment-info": {
          "authMode": "none"
        },
        "parameters": [
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            },
            "description": "Tempo wallet address (0x-prefixed, 42 chars)"
          }
        ],
        "responses": {
          "200": {
            "description": "Balance response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string"
                    },
                    "balance": {
                      "type": "string",
                      "description": "Human-readable pathUSD amount"
                    },
                    "currency": {
                      "type": "string",
                      "example": "pathUSD"
                    },
                    "raw": {
                      "type": "string",
                      "description": "Raw hex balance from EVM call"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid address format"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "mppPayment": {
        "type": "http",
        "scheme": "Payment",
        "description": "MPP HTTP 402 payment credential. Obtain via `npx mppx account create`, fund with pathUSD, then use `npx mppx <url> --method POST -J <body>` to auto-handle challenges."
      }
    }
  }
}