# Harpd Agent API — OpenAPI 3.1 contract.
#
# GENERATED FILE — do not edit by hand.
# Source of truth: collector/src/data/agent-product-catalog.ts
# Regenerate:  npm run gen:agent-contract --workspace=collector
#
# This is the same contract the Worker serves and the same prices the HTTP 402
# challenge quotes. If they ever disagree, the generator test fails.
openapi: "3.1.0"
info:
  title: "Harpd Agent API"
  version: "1.0.0"
  summary: "AI product intelligence that AI agents can discover, price, buy and cite without an account."
  description: "Harpd publishes AI product intelligence — rankings, comparisons, research and model pricing — as a machine-first API that an autonomous agent can buy per request.\n\nThere is no signup, no API key, no dashboard and no human checkout. The entire integration is an agent wallet plus an HTTP request:\n\n1. Read `/.well-known/harpd-agent.json` (or GET /api/agent/v1/manifest) to learn what Harpd sells and what it costs.\n2. Call a free endpoint to evaluate the data.\n3. Call a paid endpoint with no payment header. It returns **HTTP 402** with the exact payment requirements in the `PAYMENT-REQUIRED` header.\n4. Sign the USDC payment with the agent wallet and retry with the `PAYMENT-SIGNATURE` header.\n5. Receive the data as `{ data, meta }`, with a settlement receipt in `meta.payment` and a ready-to-quote `meta.citation`.\n\nPaid endpoints settle in USDC on Base over [x402](https://harpd.com/protocols/x402/). A settled payment is single-use: replaying it returns HTTP 409.\n\nFree endpoints (search, rank, pricing, product profiles) stay free and unauthenticated by design — an agent must be able to evaluate Harpd before it is asked to pay. Data is licensed CC BY 4.0 with attribution."
  contact:
    name: "Harpd"
    url: "https://harpd.com"
    email: "harpdsupport@gmail.com"
  license:
    name: "CC BY 4.0"
    url: "https://creativecommons.org/licenses/by/4.0/"
  x-documentation: "https://harpd.com/developers/agents/"
  x-trust: "https://harpd.com/for-agents/trust/"
  x-manifest: "https://harpd.com/.well-known/harpd-agent.json"
  x-pricing: "https://api.harpd.com/api/agent/v1/pricing"
  x-mcp: "https://api.harpd.com/mcp"
  x-llms: "https://harpd.com/llms.txt"
servers:
  - url: "https://api.harpd.com"
    description: "Production"
  - url: "https://harpd-collector-testnet.<account>.workers.dev"
    description: "Base Sepolia testnet (payments are nominal; see /for-agents/trust/)"
tags:
  - name: "discovery"
    description: "Free machine-readable capability, pricing and catalog endpoints."
  - name: "free"
    description: "Free, unauthenticated product endpoints. No payment, no key."
  - name: "paid"
    description: "Paid product endpoints. HTTP 402 with x402 payment requirements."
  - name: "mcp"
    description: "MCP tool surface, so an agent framework can buy Harpd data as a tool call."
paths:
  /api/agent/v1/search:
    get:
      operationId: "agent_search"
      summary: "Search the published Harpd AI product catalog"
      description: "Free keyword search over the published Harpd AI product catalog, with category filters and stable machine-readable results."
      tags:
        - "free"
      security: []
      parameters:
        - name: "q"
          in: "query"
          required: true
          schema:
            type: "string"
            minLength: 2
            maxLength: 200
          description: "Free-text query. At least 2 characters."
        - name: "category"
          in: "query"
          schema:
            type: "string"
          description: "Restrict to one Harpd category slug."
        - name: "limit"
          in: "query"
          schema:
            type: "integer"
            minimum: 1
            maximum: 50
            default: 10
      responses:
        200:
          description: "Successful response in the Harpd agent envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        429:
          description: "Rate limit exceeded."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
      x-payment-info:
        price:
          mode: "free"
          amount: "0.000000"
        protocols: []
        requiresPayment: false
      x-canonical: "https://harpd.com/products/"
      x-dataset: "https://harpd.com/data/products.json"
      x-methodology: "https://harpd.com/rank/methodology/"
  /api/agent/v1/rank:
    get:
      operationId: "agent_rank"
      summary: "Read the free Harpd Rank board"
      description: "Free Harpd Rank board for any scope and category, in the unified agent envelope."
      tags:
        - "free"
      security: []
      parameters:
        - name: "scope"
          in: "query"
          schema:
            type: "string"
            enum:
              - "overall"
              - "monthly"
              - "weekly"
            default: "overall"
        - name: "category"
          in: "query"
          schema:
            type: "string"
            default: "all"
        - name: "limit"
          in: "query"
          schema:
            type: "integer"
            minimum: 1
            maximum: 100
            default: 50
      responses:
        200:
          description: "Successful response in the Harpd agent envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        429:
          description: "Rate limit exceeded."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
      x-payment-info:
        price:
          mode: "free"
          amount: "0.000000"
        protocols: []
        requiresPayment: false
      x-canonical: "https://harpd.com/rank/"
      x-dataset: "https://harpd.com/data/rank.json"
      x-methodology: "https://harpd.com/rank/methodology/"
  /api/agent/v1/pricing:
    get:
      operationId: "agent_pricing"
      summary: "Machine-readable price list for every Harpd Agent API product"
      description: "Machine-readable price list for every Harpd Agent API product. The same numbers appear in the 402 challenge and the developer docs."
      tags:
        - "free"
      security: []
      parameters: []
      responses:
        200:
          description: "Successful response in the Harpd agent envelope."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        429:
          description: "Rate limit exceeded."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
      x-payment-info:
        price:
          mode: "free"
          amount: "0.000000"
        protocols: []
        requiresPayment: false
      x-canonical: "https://harpd.com/developers/agents/"
      x-dataset: "https://harpd.com/data/rank.json"
      x-methodology: "https://harpd.com/rank/methodology/"
  /api/agent/v1/compare:
    post:
      operationId: "agent_compare"
      summary: "Harpd AI product comparison"
      description: "Head-to-head comparison of 2–8 AI products: category, published rank, list pricing where the product is a priced model, and the material differences between them.\n\nPAID: 0.01 USDC per request, settled over x402 on Base. No API key, account or registration is required — the agent signs and settles the payment itself."
      tags:
        - "paid"
      security: []
      x-payment-info:
        price:
          mode: "fixed"
          currency: "USD"
          amount: "0.010000"
        protocols:
          - x402: {}
        network: "eip155:8453"
        asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        payTo: "0xc5eE10606C211867133C8A18Fe1685774970Ebb4"
        unit: "request"
      x-canonical: "https://harpd.com/compare/"
      x-dataset: "https://harpd.com/data/products.json"
      x-methodology: "https://harpd.com/rank/methodology/"
      x-agent-guidance: "Call once with no payment header to receive HTTP 402 and the exact payment requirements, then sign and retry with the PAYMENT-SIGNATURE header. A settled payment is single-use: replaying it returns 409."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompareInput"
      responses:
        200:
          description: "Successful paid response in the Harpd agent envelope. Carries meta.payment and the PAYMENT-RESPONSE header."
          headers:
            PAYMENT-RESPONSE:
              description: "Base64 x402 settlement receipt."
              schema:
                type: "string"
            X-Harpd-Payment-Status:
              schema:
                type: "string"
                const: "settled"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        400:
          description: "Input does not match the published input schema."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        402:
          description: "Payment required. Sign the x402 payment from the PAYMENT-REQUIRED header and retry."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentRequired"
        409:
          description: "This payment was already consumed. A settled payment is single-use by design."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        429:
          description: "Rate limit or daily spend limit reached."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        503:
          description: "Payment facilitator or upstream data unavailable."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
  /api/agent/v1/optimize-model:
    post:
      operationId: "agent_optimize_model"
      summary: "Harpd AI model cost optimization"
      description: "Given a task and the model currently running it, returns cheaper candidate models that still clear the task quality floor, with per-call and projected monthly savings, the performance trade-off, a confidence value and the evidence behind every number.\n\nPAID: 0.05 USDC per request, settled over x402 on Base. No API key, account or registration is required — the agent signs and settles the payment itself."
      tags:
        - "paid"
      security: []
      x-payment-info:
        price:
          mode: "fixed"
          currency: "USD"
          amount: "0.050000"
        protocols:
          - x402: {}
        network: "eip155:8453"
        asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        payTo: "0xc5eE10606C211867133C8A18Fe1685774970Ebb4"
        unit: "request"
      x-canonical: "https://harpd.com/llm-cost-optimization/"
      x-dataset: "https://harpd.com/data/llm-pricing.json"
      x-methodology: "https://harpd.com/methodology/cost-per-successful-task/"
      x-agent-guidance: "Call once with no payment header to receive HTTP 402 and the exact payment requirements, then sign and retry with the PAYMENT-SIGNATURE header. A settled payment is single-use: replaying it returns 409."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OptimizeModelInput"
      responses:
        200:
          description: "Successful paid response in the Harpd agent envelope. Carries meta.payment and the PAYMENT-RESPONSE header."
          headers:
            PAYMENT-RESPONSE:
              description: "Base64 x402 settlement receipt."
              schema:
                type: "string"
            X-Harpd-Payment-Status:
              schema:
                type: "string"
                const: "settled"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        400:
          description: "Input does not match the published input schema."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        402:
          description: "Payment required. Sign the x402 payment from the PAYMENT-REQUIRED header and retry."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentRequired"
        409:
          description: "This payment was already consumed. A settled payment is single-use by design."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        429:
          description: "Rate limit or daily spend limit reached."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        503:
          description: "Payment facilitator or upstream data unavailable."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
  /api/agent/v1/research:
    post:
      operationId: "agent_research"
      summary: "Harpd AI product research"
      description: "A structured research answer over the Harpd catalog: matching products, category distribution, price bands, evidence per claim and the sources behind them.\n\nPAID: 0.05 USDC per request, settled over x402 on Base. No API key, account or registration is required — the agent signs and settles the payment itself."
      tags:
        - "paid"
      security: []
      x-payment-info:
        price:
          mode: "fixed"
          currency: "USD"
          amount: "0.050000"
        protocols:
          - x402: {}
        network: "eip155:8453"
        asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        payTo: "0xc5eE10606C211867133C8A18Fe1685774970Ebb4"
        unit: "request"
      x-canonical: "https://harpd.com/research/"
      x-dataset: "https://harpd.com/data/research.json"
      x-methodology: "https://harpd.com/rank/methodology/"
      x-agent-guidance: "Call once with no payment header to receive HTTP 402 and the exact payment requirements, then sign and retry with the PAYMENT-SIGNATURE header. A settled payment is single-use: replaying it returns 409."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResearchInput"
      responses:
        200:
          description: "Successful paid response in the Harpd agent envelope. Carries meta.payment and the PAYMENT-RESPONSE header."
          headers:
            PAYMENT-RESPONSE:
              description: "Base64 x402 settlement receipt."
              schema:
                type: "string"
            X-Harpd-Payment-Status:
              schema:
                type: "string"
                const: "settled"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        400:
          description: "Input does not match the published input schema."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        402:
          description: "Payment required. Sign the x402 payment from the PAYMENT-REQUIRED header and retry."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentRequired"
        409:
          description: "This payment was already consumed. A settled payment is single-use by design."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        429:
          description: "Rate limit or daily spend limit reached."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        503:
          description: "Payment facilitator or upstream data unavailable."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
  /api/agent/v1/dataset/query:
    post:
      operationId: "agent_dataset_query"
      summary: "Harpd structured dataset query"
      description: "Field-selective, filtered queries against the published Harpd datasets (ai-products, model-pricing) with row and field projection.\n\nPAID: 0.02 USDC per request, settled over x402 on Base. No API key, account or registration is required — the agent signs and settles the payment itself."
      tags:
        - "paid"
      security: []
      x-payment-info:
        price:
          mode: "fixed"
          currency: "USD"
          amount: "0.020000"
        protocols:
          - x402: {}
        network: "eip155:8453"
        asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        payTo: "0xc5eE10606C211867133C8A18Fe1685774970Ebb4"
        unit: "request"
        rowBands:
          - maxRows: 100
            amount: "0.020000"
            amountAtomic: "20000"
          - maxRows: 500
            amount: "0.050000"
            amountAtomic: "50000"
        note: "The amount quoted in the 402 challenge is resolved from the requested row count, so the challenge is always the exact charge."
      x-canonical: "https://harpd.com/data/"
      x-dataset: "https://harpd.com/data/products.json"
      x-methodology: "https://harpd.com/rank/methodology/"
      x-agent-guidance: "Call once with no payment header to receive HTTP 402 and the exact payment requirements, then sign and retry with the PAYMENT-SIGNATURE header. A settled payment is single-use: replaying it returns 409."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DatasetQueryInput"
      responses:
        200:
          description: "Successful paid response in the Harpd agent envelope. Carries meta.payment and the PAYMENT-RESPONSE header."
          headers:
            PAYMENT-RESPONSE:
              description: "Base64 x402 settlement receipt."
              schema:
                type: "string"
            X-Harpd-Payment-Status:
              schema:
                type: "string"
                const: "settled"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentEnvelope"
        400:
          description: "Input does not match the published input schema."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        402:
          description: "Payment required. Sign the x402 payment from the PAYMENT-REQUIRED header and retry."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentRequired"
        409:
          description: "This payment was already consumed. A settled payment is single-use by design."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        429:
          description: "Rate limit or daily spend limit reached."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        503:
          description: "Payment facilitator or upstream data unavailable."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
  /api/agent/v1/manifest:
    get:
      operationId: "agent_manifest"
      summary: "Agent capability manifest"
      description: "Capabilities, endpoints, payment rails, formats and limits. The machine front door to Harpd."
      tags:
        - "discovery"
      security: []
      responses:
        200:
          description: "Capability manifest"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentManifest"
  /api/agent/v1/products:
    get:
      operationId: "agent_products"
      summary: "Product catalog"
      description: "Every Harpd Agent API product with its price, input schema and canonical page."
      tags:
        - "discovery"
      security: []
      responses:
        200:
          description: "Product catalog"
  "/api/agent/v1/products/{slug}":
    get:
      operationId: "agent_product_profile"
      summary: "Single product profile (legacy free endpoint, unchanged)"
      tags:
        - "free"
      security: []
      parameters:
        - name: "slug"
          in: "path"
          required: true
          schema:
            type: "string"
      responses:
        200:
          description: "Product profile"
        404:
          description: "Not found"
  /api/agent/v1/rankings:
    get:
      operationId: "agent_rankings_legacy"
      summary: "Free Harpd Rank data (legacy shape)"
      description: "Superseded by /api/agent/v1/rank, which returns the unified envelope. Kept unchanged so existing agent integrations keep working."
      tags:
        - "free"
      security: []
      deprecated: true
      parameters:
        - name: "scope"
          in: "query"
          schema:
            type: "string"
            enum:
              - "overall"
              - "monthly"
              - "weekly"
        - name: "category"
          in: "query"
          schema:
            type: "string"
      responses:
        200:
          description: "Free Harpd Rank data"
  /mcp:
    get:
      operationId: "mcp_discovery"
      summary: "MCP tool catalog"
      description: "Lists the MCP tools, their price and how payment works, without a JSON-RPC round trip."
      tags:
        - "mcp"
      security: []
      responses:
        200:
          description: "MCP server descriptor and tool list"
    post:
      operationId: "mcp_jsonrpc"
      summary: "MCP JSON-RPC endpoint"
      description: "JSON-RPC 2.0 over HTTP. Supports initialize, tools/list, resources/list and tools/call. Paid tools return HTTP 402 with x402 payment requirements, so one x402 client handles both MCP and REST."
      tags:
        - "mcp"
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: "object"
              required:
                - "jsonrpc"
                - "method"
              properties:
                jsonrpc:
                  type: "string"
                  const: "2.0"
                id:
                  oneOf:
                    - type: "string"
                    - type: "number"
                    - type: "null"
                method:
                  type: "string"
                  enum:
                    - "initialize"
                    - "notifications/initialized"
                    - "tools/list"
                    - "tools/call"
                    - "resources/list"
                    - "prompts/list"
                params:
                  type: "object"
                  properties:
                    name:
                      type: "string"
                      description: "Tool name for tools/call."
                    arguments:
                      type: "object"
                      description: "Tool arguments."
      responses:
        200:
          description: "JSON-RPC result"
        202:
          description: "Notification accepted"
        400:
          description: "Input does not match the published input schema."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        402:
          description: "Payment required. Sign the x402 payment from the PAYMENT-REQUIRED header and retry."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaymentRequired"
        409:
          description: "This payment was already consumed. A settled payment is single-use by design."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        429:
          description: "Rate limit or daily spend limit reached."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
        503:
          description: "Payment facilitator or upstream data unavailable."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentError"
components:
  schemas:
    AgentEnvelope:
      type: "object"
      required:
        - "data"
        - "meta"
      properties:
        data:
          type: "object"
          description: "The product payload. Shape is documented per operation below."
        meta:
          type: "object"
          required:
            - "source"
            - "version"
            - "updated_at"
            - "methodology"
            - "canonical"
            - "dataset"
            - "license"
            - "citation"
            - "request_id"
            - "free"
            - "payment"
          properties:
            source:
              type: "string"
              const: "Harpd"
            version:
              type: "string"
              const: "1"
              description: "Envelope schema version. Breaking changes bump this."
            updated_at:
              type: "string"
              format: "date-time"
            methodology:
              type: "string"
              format: "uri"
            canonical:
              type: "string"
              format: "uri"
            dataset:
              type: "string"
              format: "uri"
            license:
              type: "string"
              const: "CC BY 4.0"
            citation:
              type: "object"
              required:
                - "text"
                - "url"
                - "dataset"
                - "methodology"
                - "retrieved_at"
              properties:
                text:
                  type: "string"
                  description: "Ready-to-quote attribution line."
                url:
                  type: "string"
                  format: "uri"
                  description: "Canonical Harpd page for this data."
                dataset:
                  type: "string"
                  format: "uri"
                  description: "The dataset this answer derives from."
                methodology:
                  type: "string"
                  format: "uri"
                  description: "The published method behind every number."
                retrieved_at:
                  type: "string"
                  format: "date-time"
            request_id:
              type: "string"
            free:
              type: "boolean"
              description: "True when no payment was required for this response."
            payment:
              type:
                - "object"
                - "null"
              description: "Always present. null on a free response; the settled receipt on a paid one. Mirrors the PAYMENT-RESPONSE header."
              properties:
                status:
                  type: "string"
                  const: "settled"
                network:
                  type: "string"
                  examples:
                    - "eip155:8453"
                currency:
                  type: "string"
                  const: "USDC"
                amount:
                  type: "string"
                  description: "Human decimal USDC amount, e.g. \"0.05\"."
                amount_atomic:
                  type: "string"
                  description: "USDC atomic units (6 decimals), e.g. \"50000\"."
                resource:
                  type: "string"
                  format: "uri"
                product:
                  type: "string"
                transaction:
                  type:
                    - "string"
                    - "null"
                  description: "Facilitator settlement transaction reference."
                payer_reference:
                  type:
                    - "string"
                    - "null"
                timestamp:
                  type: "string"
                  format: "date-time"
                receipt_hash:
                  type: "string"
                  description: "SHA-256 receipt hash. Unique per settled payment; a replayed payment is refused with 409."
    AgentMeta:
      type: "object"
      required:
        - "source"
        - "version"
        - "updated_at"
        - "methodology"
        - "canonical"
        - "dataset"
        - "license"
        - "citation"
        - "request_id"
        - "free"
        - "payment"
      properties:
        source:
          type: "string"
          const: "Harpd"
        version:
          type: "string"
          const: "1"
          description: "Envelope schema version. Breaking changes bump this."
        updated_at:
          type: "string"
          format: "date-time"
        methodology:
          type: "string"
          format: "uri"
        canonical:
          type: "string"
          format: "uri"
        dataset:
          type: "string"
          format: "uri"
        license:
          type: "string"
          const: "CC BY 4.0"
        citation:
          type: "object"
          required:
            - "text"
            - "url"
            - "dataset"
            - "methodology"
            - "retrieved_at"
          properties:
            text:
              type: "string"
              description: "Ready-to-quote attribution line."
            url:
              type: "string"
              format: "uri"
              description: "Canonical Harpd page for this data."
            dataset:
              type: "string"
              format: "uri"
              description: "The dataset this answer derives from."
            methodology:
              type: "string"
              format: "uri"
              description: "The published method behind every number."
            retrieved_at:
              type: "string"
              format: "date-time"
        request_id:
          type: "string"
        free:
          type: "boolean"
          description: "True when no payment was required for this response."
        payment:
          type:
            - "object"
            - "null"
          description: "Always present. null on a free response; the settled receipt on a paid one. Mirrors the PAYMENT-RESPONSE header."
          properties:
            status:
              type: "string"
              const: "settled"
            network:
              type: "string"
              examples:
                - "eip155:8453"
            currency:
              type: "string"
              const: "USDC"
            amount:
              type: "string"
              description: "Human decimal USDC amount, e.g. \"0.05\"."
            amount_atomic:
              type: "string"
              description: "USDC atomic units (6 decimals), e.g. \"50000\"."
            resource:
              type: "string"
              format: "uri"
            product:
              type: "string"
            transaction:
              type:
                - "string"
                - "null"
              description: "Facilitator settlement transaction reference."
            payer_reference:
              type:
                - "string"
                - "null"
            timestamp:
              type: "string"
              format: "date-time"
            receipt_hash:
              type: "string"
              description: "SHA-256 receipt hash. Unique per settled payment; a replayed payment is refused with 409."
    AgentCitation:
      type: "object"
      required:
        - "text"
        - "url"
        - "dataset"
        - "methodology"
        - "retrieved_at"
      properties:
        text:
          type: "string"
          description: "Ready-to-quote attribution line."
        url:
          type: "string"
          format: "uri"
          description: "Canonical Harpd page for this data."
        dataset:
          type: "string"
          format: "uri"
          description: "The dataset this answer derives from."
        methodology:
          type: "string"
          format: "uri"
          description: "The published method behind every number."
        retrieved_at:
          type: "string"
          format: "date-time"
    AgentError:
      type: "object"
      required:
        - "error"
        - "message"
        - "request_id"
        - "documentation"
      properties:
        error:
          type: "string"
          description: "Stable machine-readable error code."
        message:
          type: "string"
        request_id:
          type: "string"
        documentation:
          type: "string"
          format: "uri"
        product:
          type: "string"
        validation_errors:
          type: "array"
          items:
            type: "string"
        input_schema:
          type: "object"
    PaymentRequired:
      type: "object"
      description: "x402 v2 challenge. Also returned base64-encoded in the PAYMENT-REQUIRED response header, which is what the standard x402 client reads."
      required:
        - "error"
        - "request_id"
        - "payment"
      properties:
        error:
          type: "string"
          const: "PAYMENT_REQUIRED"
        request_id:
          type: "string"
        payment:
          type: "object"
          properties:
            x402Version:
              type: "integer"
              const: 2
            resource:
              type: "object"
              properties:
                url:
                  type: "string"
                  format: "uri"
                description:
                  type: "string"
                mimeType:
                  type: "string"
                  const: "application/json"
                serviceName:
                  type: "string"
                tags:
                  type: "array"
                  items:
                    type: "string"
            accepts:
              type: "array"
              items:
                type: "object"
                required:
                  - "scheme"
                  - "network"
                  - "asset"
                  - "amount"
                  - "payTo"
                properties:
                  scheme:
                    type: "string"
                    const: "exact"
                  network:
                    type: "string"
                    examples:
                      - "eip155:8453"
                  asset:
                    type: "string"
                  amount:
                    type: "string"
                    description: "USDC atomic units."
                  payTo:
                    type: "string"
                  maxTimeoutSeconds:
                    type: "integer"
                  resource:
                    type: "string"
                    format: "uri"
            extensions:
              type: "object"
              description: "Bazaar discovery extension: input shape and output schema, so an agent can learn the call from the 402 alone."
    AgentManifest:
      type: "object"
      required:
        - "name"
        - "capabilities"
        - "endpoints"
        - "payment"
        - "free_products"
        - "paid_products"
      properties:
        name:
          type: "string"
          const: "Harpd"
        description:
          type: "string"
        version:
          type: "string"
        capabilities:
          type: "array"
          items:
            type: "string"
        endpoints:
          type: "object"
        payment:
          type: "object"
          properties:
            protocols:
              type: "array"
              items:
                type: "string"
            currency:
              type: "string"
              const: "USDC"
            network:
              type: "string"
            network_id:
              type: "string"
            chain_id:
              type: "integer"
            mode:
              type: "string"
              enum:
                - "mainnet"
                - "testnet"
                - "disabled"
            requires_account:
              type: "boolean"
              const: false
            requires_api_key:
              type: "boolean"
              const: false
            requires_human_checkout:
              type: "boolean"
              const: false
        free_products:
          type: "array"
          items:
            type: "string"
        paid_products:
          type: "array"
          items:
            type: "object"
            properties:
              product:
                type: "string"
              endpoint:
                type: "string"
                format: "uri"
              price:
                type: "string"
              currency:
                type: "string"
                const: "USDC"
              unit:
                type: "string"
                const: "request"
        documentation:
          type: "string"
          format: "uri"
        trust:
          type: "string"
          format: "uri"
        spend_limits:
          type: "object"
        rate_limits:
          type: "object"
    CompareInput:
      type: "object"
      properties:
        products:
          type: "array"
          minItems: 2
          maxItems: 8
          items:
            type: "string"
      required:
        - "products"
      additionalProperties: false
    OptimizeModelInput:
      type: "object"
      properties:
        task:
          type: "string"
          minLength: 3
          maxLength: 2000
        current_model:
          type: "string"
        max_cost:
          type: "number"
          exclusiveMinimum: 0
        monthly_calls:
          type: "integer"
          minimum: 1
          maximum: 100000000
        constraints:
          type: "object"
          properties:
            min_context_window:
              type: "integer"
              minimum: 1000
            min_tier:
              type: "string"
              enum:
                - "mini"
                - "fast"
                - "open"
                - "reasoning"
                - "flagship"
            providers:
              type: "array"
              items:
                type: "string"
          additionalProperties: false
      required:
        - "task"
        - "current_model"
      additionalProperties: false
    ResearchInput:
      type: "object"
      properties:
        query:
          type: "string"
          minLength: 3
          maxLength: 500
        limit:
          type: "integer"
          minimum: 1
          maximum: 50
          default: 15
      required:
        - "query"
      additionalProperties: false
    DatasetQueryInput:
      type: "object"
      properties:
        dataset:
          type: "string"
          enum:
            - "ai-products"
            - "model-pricing"
        filters:
          type: "object"
        fields:
          type: "array"
          items:
            type: "string"
        limit:
          type: "integer"
          minimum: 1
          maximum: 500
          default: 50
      required:
        - "dataset"
      additionalProperties: false
  securitySchemes: {}
x-payment-protocols:
  - protocol: "x402"
    version: 2
    network: "eip155:8453"
    chain_id: 8453
    currency: "USDC"
    asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    payTo: "0xc5eE10606C211867133C8A18Fe1685774970Ebb4"
    flow:
      - "request"
      - "402_payment_required"
      - "sign_payment"
      - "retry"
      - "verify"
      - "settle"
      - "200_json"
    requiresAccount: false
    requiresApiKey: false
    requiresHumanCheckout: false
x-spend-limits:
  max_per_request_usd: 1
  daily_usd: 10
  wallet_allowlist_enabled: false
x-rate-limits:
  requests_per_minute: 120
