{
  "openapi": "3.1.0",
  "info": {
    "title": "Paperknife PDF Extraction API",
    "version": "1.0.0",
    "description": "Convert public PDF URLs to clean, page-aware JSON for RAG indexing, LLM ingestion, document search, and autonomous agent pipelines. Pay per call with x402 USDC on Base; no API key or account.",
    "contact": { "url": "https://paperknife-api.davidgoparkid369.chatgpt.site" },
    "x-guidance": "Use POST /api/extract when page-aware text, metadata, and links are needed for a complete PDF. Send a public HTTPS PDF URL in the JSON body. The endpoint accepts PDFs up to 20 MB and 100 pages."
  },
  "servers": [{ "url": "https://paperknife-api.davidgoparkid369.chatgpt.site" }],
  "paths": {
    "/api/extract": {
      "post": {
        "operationId": "extractPdf",
        "summary": "Convert a PDF URL to page-aware text and metadata JSON",
        "description": "Extract the complete text layer, per-page content, title, author, metadata, and links from a public HTTPS PDF. Designed for PDF-to-JSON conversion, RAG ingestion, vector indexing, document parsing, and LLM agent workflows. Supports files up to 20 MB and 100 pages. No signup or API key; fixed $0.003 USDC payment over x402 on Base.",
        "tags": ["Documents", "PDF", "RAG"],
        "x-payment-info": {
          "price": { "mode": "fixed", "currency": "USD", "amount": "0.003000" },
          "protocols": [{ "x402": {} }]
        },
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Input" } } } },
        "responses": {
          "200": { "description": "Complete page-aware extraction", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Extraction" } } } },
          "400": { "description": "Invalid request or PDF" },
          "402": { "description": "x402 payment required" }
        }
      }
    },
    "/a2a": {
      "post": {
        "operationId": "sendPdfExtractionMessage",
        "summary": "Use Paperknife through the A2A 1.0 JSON-RPC protocol",
        "description": "Send a PDF URL in an A2A data or text part. Requests with params.metadata.preview=true return the first page free. Full extraction costs $0.003 USDC over x402 on Base.",
        "tags": ["A2A", "Documents", "PDF", "RAG"],
        "x-payment-info": {
          "price": { "mode": "fixed", "currency": "USD", "amount": "0.003000" },
          "protocols": [{ "x402": {} }],
          "freePreview": true
        },
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/A2ASendMessage" } } } },
        "responses": {
          "200": { "description": "A2A response containing extracted PDF data", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } },
          "400": { "description": "Invalid JSON-RPC or PDF request" },
          "402": { "description": "x402 payment required for full extraction" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Input": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url"],
        "properties": { "url": { "type": "string", "format": "uri", "description": "Public HTTPS URL of a PDF up to 20 MB and 100 pages" } }
      },
      "A2ASendMessage": {
        "type": "object",
        "additionalProperties": false,
        "required": ["jsonrpc", "id", "method", "params"],
        "properties": {
          "jsonrpc": { "const": "2.0" },
          "id": { "type": ["string", "number"] },
          "method": { "enum": ["SendMessage", "message/send"] },
          "params": {
            "type": "object",
            "required": ["message"],
            "properties": {
              "message": { "type": "object", "description": "A2A Message with a public PDF URL in a data part as {url}, or in a text part." },
              "metadata": { "type": "object", "properties": { "preview": { "type": "boolean", "description": "Set true for a free first-page preview." } } }
            }
          }
        }
      },
      "Extraction": {
        "type": "object",
        "required": ["sourceUrl", "pages", "bytes", "title", "author", "text", "byPage", "links", "preview", "elapsedMs"],
        "properties": {
          "sourceUrl": { "type": "string", "format": "uri" },
          "pages": { "type": "integer", "minimum": 1 },
          "bytes": { "type": "integer", "minimum": 1 },
          "title": { "type": ["string", "null"] },
          "author": { "type": ["string", "null"] },
          "metadata": { "type": "object", "additionalProperties": true },
          "text": { "type": "string" },
          "byPage": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["page", "text"],
              "properties": { "page": { "type": "integer", "minimum": 1 }, "text": { "type": "string" } }
            }
          },
          "links": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "preview": { "type": "boolean" },
          "elapsedMs": { "type": "integer", "minimum": 0 }
        }
      }
    }
  }
}
