{
  "openapi": "3.1.0",
  "info": {
    "title": "UtilsForAgents API",
    "description": "High-speed utility microservices for AI agents \u2014 JSON diff, image EXIF/scrub, HTML-to-Markdown, text extraction, URL metadata, token counting, plus a free feedback endpoint. Paid utility routes use the x402 payment protocol (HTTP 402 + USDC on Base or Solana); POST /v1/feedback is free and unauthenticated.",
    "version": "2.2.0",
    "contact": {
      "name": "UtilsForAgents",
      "url": "https://utilsforagents.com"
    },
    "license": {
      "name": "Proprietary"
    },
    "x-guidance": "UtilsForAgents provides eight paid utility endpoints for AI agents plus one free feedback endpoint. Paid utility calls cost $0.003 USD each and use the x402 v2 payment protocol \u2014 no API keys or accounts needed. POST /v1/feedback is free, unauthenticated, and excluded from x402 discovery.\n\nPayment flow for paid utility routes:\n1. POST JSON (or binary for image endpoints) to a paid /v1/* utility path.\n2. The server replies HTTP 402 with a `PAYMENT-REQUIRED` header (base64-encoded JSON containing an `accepts` array of payment requirements).\n3. Choose one returned payment requirement and sign the matching USDC payment for that network. Current production options are Base mainnet (`eip155:8453`) and Solana mainnet (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`).\n4. Retry the identical request with a `PAYMENT-SIGNATURE` header (base64-encoded payment payload).\n5. On valid payment the server returns the normal 200 result with a `PAYMENT-RESPONSE` header containing settlement details.\n\nEndpoints at a glance:\n\u2022 POST /v1/diff \u2014 structural JSON diff (RFC 6902 ops, RFC 6901 pointers). Send {\"left\": ..., \"right\": ...}.\n\u2022 POST /v1/image/exif-summary \u2014 EXIF extraction from JPEG. Send raw image/jpeg binary body.\n\u2022 POST /v1/image/scrub-metadata \u2014 strip EXIF/XMP/IPTC from JPEG or PNG. Send raw binary body, returns cleaned image.\n\u2022 POST /v1/html/to-markdown \u2014 convert an HTML string to Markdown. Send {\"html\": \"...\"}.\n\u2022 POST /v1/html/fetch-markdown \u2014 fetch a URL, convert its HTML to Markdown. Send {\"url\": \"...\"}.\n\u2022 POST /v1/text/fetch-content \u2014 fetch a URL, auto-detect format, return Markdown/text. Send {\"url\": \"...\"}.\n\u2022 POST /v1/url/metadata \u2014 fetch a URL, extract Open Graph / Twitter Card / meta tags. Send {\"url\": \"...\"}.\n\u2022 POST /v1/utilities/count-tokens \u2014 count tokens for LLM input. Send {\"text\": \"...\"}.\n\u2022 POST /v1/feedback \u2014 submit product or feature feedback for agents. Send {\"text\": \"...\"}. Free, max 600 chars.\n\nGET /health and POST /v1/feedback are free and unauthenticated.\n\nAll JSON endpoints accept Content-Type: application/json. Image endpoints accept image/jpeg or image/png. Max upload: 5 MB. Remote-fetch endpoints limit downloaded content to 2 MB and time out after 5 s."
  },
  "servers": [
    {
      "url": "https://utilsforagents.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "healthCheck",
        "summary": "Health check",
        "description": "Returns service status. Not gated by payment.",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "service": {
                      "type": "string",
                      "example": "utilsforagents"
                    },
                    "version": {
                      "type": "string",
                      "example": "1.5.0"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/feedback": {
      "post": {
        "operationId": "submitFeedback",
        "summary": "Submit product feedback",
        "description": "Accepts short product or feature feedback from agents. This endpoint is free, unauthenticated, trims surrounding whitespace before validation, enforces a 600-character limit on the trimmed text, logs the feedback for internal review, and returns an acknowledgement.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Feedback accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedbackResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/diff": {
      "post": {
        "operationId": "jsonDiff",
        "summary": "JSON structural diff",
        "description": "Computes a structural diff between two structured JSON values. Top-level left and right inputs must each be a JSON object or array. Nulls and primitives are rejected with a 422 problem detail response. Returns RFC 6902-style patch operations with statistics.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiffRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diff computed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiffResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/image/exif-summary": {
      "post": {
        "operationId": "exifSummary",
        "summary": "Extract EXIF data from JPEG",
        "description": "Parses EXIF metadata from a JPEG image uploaded as a raw binary body. Returns structured EXIF fields. Invalid images and JPEGs without EXIF both return a 415 problem detail response.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "EXIF data extracted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "processingTimeMs": {
                      "type": "number"
                    },
                    "exif": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMedia"
          }
        }
      }
    },
    "/v1/image/scrub-metadata": {
      "post": {
        "operationId": "scrubMetadata",
        "summary": "Strip metadata from image",
        "description": "Removes all metadata (EXIF, XMP, ICC, IPTC, and other non-rendering payloads) from JPEG or PNG images. Returns the scrubbed image as binary while preserving the underlying image data.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scrubbed image",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMedia"
          }
        }
      }
    },
    "/v1/html/to-markdown": {
      "post": {
        "operationId": "htmlToMarkdown",
        "summary": "Convert HTML to Markdown",
        "description": "Converts an HTML string to clean Markdown. Accepts JSON body with an 'html' field or raw HTML body. Rejects empty bodies and empty html strings.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "html"
                ],
                "properties": {
                  "html": {
                    "type": "string",
                    "description": "HTML string to convert"
                  }
                }
              }
            },
            "text/html": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Markdown conversion result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarkdownResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/html/fetch-markdown": {
      "post": {
        "operationId": "fetchMarkdown",
        "summary": "Fetch URL and convert to Markdown",
        "description": "Fetches a URL, extracts the HTML, and converts it to Markdown. Only public http/https URLs are allowed. Non-2xx upstream responses, timeouts, and blocked SSRF targets return problem detail errors.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UrlRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Fetched and converted to Markdown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FetchMarkdownResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/text/fetch-content": {
      "post": {
        "operationId": "fetchContent",
        "summary": "Fetch and extract text content",
        "description": "Fetches a URL and auto-detects the format (HTML, JSON, Markdown, text). The response now includes both the decoded upstream body in 'content' and normalized readable text in 'text'. The legacy 'markdown' field is preserved as a backward-compatible alias of 'text'. HTML is converted to Markdown, JSON is flattened to readable text, and Markdown/plain text are returned as-is.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UrlRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Content extracted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FetchContentResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/url/metadata": {
      "post": {
        "operationId": "urlMetadata",
        "summary": "Extract URL metadata",
        "description": "Fetches a URL and extracts structured metadata: title, description, canonical URL, language, favicon, feeds, Open Graph, Twitter Card, and selected meta tags. Missing scalar fields are returned as null; feeds default to an empty array; metadata maps default to empty objects.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UrlRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Metadata extracted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UrlMetadataResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    },
    "/v1/utilities/count-tokens": {
      "post": {
        "operationId": "countTokens",
        "summary": "Count tokens for LLM input",
        "description": "Count tokens in a text string using WASM-based BPE tokenization (exact for OpenAI models) or high-fidelity estimation (Claude, Gemini). Supported encodings are cl100k_base, o200k_base, claude, and gemini. Base64 image strings can be estimated by setting content_type=image or by matching common image prefixes. Max input: 50 MB.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {
                "version": 2,
                "network": "eip155:8453"
              }
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CountTokensRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tokens counted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountTokensResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "402": {
            "description": "Payment Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/x402Response"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "422": {
            "$ref": "#/components/responses/InvalidSchema"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "FeedbackRequest": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 600,
            "description": "Feedback text to log for product planning. Leading and trailing whitespace is trimmed before validation; the trimmed value must contain 1 to 600 characters. Non-string values and trimmed-empty values return a 400 problem detail response."
          }
        }
      },
      "FeedbackResponse": {
        "type": "object",
        "required": ["ok", "accepted", "maxChars"],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "accepted": {
            "type": "boolean",
            "example": true
          },
          "maxChars": {
            "type": "integer",
            "example": 600
          }
        }
      },
      "DiffRequest": {
        "type": "object",
        "required": [
          "left",
          "right"
        ],
        "properties": {
          "left": {
            "oneOf": [
              { "type": "object", "additionalProperties": true },
              { "type": "array", "items": {} }
            ],
            "description": "Left-hand structured JSON value to compare. Must be a JSON object or array. Nulls and primitives are rejected."
          },
          "right": {
            "oneOf": [
              { "type": "object", "additionalProperties": true },
              { "type": "array", "items": {} }
            ],
            "description": "Right-hand structured JSON value to compare. Must be a JSON object or array. Nulls and primitives are rejected."
          },
          "options": {
            "type": "object",
            "description": "Optional diff settings. Invalid option types return a 422 problem detail response.",
            "properties": {
              "includeUnchanged": {
                "type": "boolean",
                "default": false,
                "description": "Count unchanged fields in stats"
              },
              "maxDepth": {
                "type": "integer",
                "minimum": 1,
                "maximum": 256,
                "default": 64,
                "description": "Maximum recursion depth"
              }
            }
          }
        }
      },
      "DiffResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "stats": {
            "type": "object",
            "properties": {
              "added": {
                "type": "integer"
              },
              "removed": {
                "type": "integer"
              },
              "changed": {
                "type": "integer"
              },
              "unchanged": {
                "type": "integer"
              },
              "processingTimeMs": {
                "type": "number"
              }
            }
          },
          "diff": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "op": {
                  "type": "string",
                  "enum": [
                    "add",
                    "remove",
                    "replace"
                  ]
                },
                "path": {
                  "type": "string",
                  "description": "JSON Pointer (RFC 6901)"
                },
                "value": {},
                "oldValue": {},
                "newValue": {}
              }
            }
          }
        }
      },
      "UrlRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL to fetch"
          }
        }
      },
      "MarkdownResponse": {
        "type": "object",
        "required": ["ok", "processingTimeMs", "charsBefore", "charsAfter", "markdown"],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "processingTimeMs": {
            "type": "number"
          },
          "charsBefore": {
            "type": "integer"
          },
          "charsAfter": {
            "type": "integer"
          },
          "markdown": {
            "type": "string"
          }
        }
      },
      "FetchMarkdownResponse": {
        "type": "object",
        "required": ["ok", "processingTimeMs", "sourceUrl", "charsBefore", "charsAfter", "markdown"],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "processingTimeMs": {
            "type": "number"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "charsBefore": {
            "type": "integer"
          },
          "charsAfter": {
            "type": "integer"
          },
          "markdown": {
            "type": "string"
          }
        }
      },
      "FetchContentResponse": {
        "type": "object",
        "required": ["ok", "processingTimeMs", "sourceUrl", "contentType", "detectedFormat", "charsBefore", "charsAfter", "content", "text", "markdown"],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "processingTimeMs": {
            "type": "number"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "contentType": {
            "type": "string",
            "description": "Upstream response content type without charset parameters when available"
          },
          "detectedFormat": {
            "type": "string",
            "enum": [
              "html",
              "json",
              "markdown",
              "text"
            ]
          },
          "charsBefore": {
            "type": "integer"
          },
          "charsAfter": {
            "type": "integer"
          },
          "content": {
            "type": "string",
            "description": "Decoded upstream response body as text"
          },
          "text": {
            "type": "string",
            "description": "Normalized readable text extracted from the upstream response"
          },
          "markdown": {
            "type": "string",
            "description": "Backward-compatible alias of the 'text' field"
          }
        }
      },
      "UrlMetadataResponse": {
        "type": "object",
        "required": ["ok", "processingTimeMs", "sourceUrl", "metadata"],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "processingTimeMs": {
            "type": "number"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "metadata": {
            "type": "object",
            "description": "Extracted page metadata including title, description, Open Graph, Twitter Card, canonical URL, language, etc.",
            "properties": {
              "title": {
                "type": "string",
                "nullable": true,
                "description": "Document title when present; null otherwise"
              },
              "description": {
                "type": "string",
                "nullable": true,
                "description": "Meta description or Open Graph fallback; null otherwise"
              },
              "canonical": {
                "type": "string",
                "format": "uri",
                "nullable": true,
                "description": "Canonical URL when declared; null otherwise"
              },
              "language": {
                "type": "string",
                "nullable": true,
                "description": "html[lang] value when present; null otherwise"
              },
              "favicon": {
                "type": "string",
                "nullable": true,
                "description": "Resolved favicon URL when present; null otherwise"
              },
              "feeds": {
                "type": "array",
                "description": "RSS or Atom feed links discovered in the document head. Empty when none are present.",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": { "type": "string" },
                    "href": { "type": "string", "format": "uri" },
                    "title": { "type": "string", "nullable": true }
                  }
                }
              },
              "openGraph": {
                "type": "object",
                "description": "Map of og:* tags. Empty object when no Open Graph tags are present.",
                "additionalProperties": true
              },
              "twitterCard": {
                "type": "object",
                "description": "Map of twitter:* tags. Empty object when no Twitter Card tags are present.",
                "additionalProperties": true
              },
              "meta": {
                "type": "object",
                "description": "Selected standard meta tags such as author, keywords, robots, and generator. Empty object when none are present.",
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        }
      },
      "ProblemDetail": {
        "type": "object",
        "description": "RFC 9457 Problem Details",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "CountTokensRequest": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "Text to tokenize (max 50 MB). For image estimation, pass a base64-encoded image string and set content_type=image."
          },
          "encoding": {
            "type": "string",
            "enum": ["cl100k_base", "o200k_base", "claude", "gemini"],
            "default": "cl100k_base",
            "description": "Tokenizer encoding. cl100k_base and o200k_base are exact (WASM BPE). claude and gemini are high-fidelity estimates."
          },
          "content_type": {
            "type": "string",
            "enum": ["text", "image"],
            "default": "text",
            "description": "Input content type. Use 'image' for base64-encoded image strings (returns estimated token count)."
          }
        }
      },
      "CountTokensResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "processingTimeMs": {
            "type": "number",
            "description": "Server-side processing time in milliseconds"
          },
          "encoding": {
            "type": "string",
            "description": "The encoding used for tokenization"
          },
          "method": {
            "type": "string",
            "enum": ["exact", "estimate"],
            "description": "'exact' for WASM BPE (OpenAI encodings), 'estimate' for heuristic-based (Claude, Gemini, images)"
          },
          "tokenCount": {
            "type": "integer",
            "description": "Number of tokens in the input"
          },
          "characterCount": {
            "type": "integer",
            "description": "Number of characters in the (potentially sanitized) input"
          },
          "utf8Sanitized": {
            "type": "boolean",
            "description": "True if malformed UTF-8 sequences were replaced with U+FFFD before tokenization"
          }
        }
      },
      "x402Response": {
        "type": "object",
        "description": "x402 v2 Payment Required response. Payment requirements are also sent in the PAYMENT-REQUIRED header (base64-encoded).",
        "required": [
          "x402Version",
          "accepts"
        ],
        "properties": {
          "x402Version": {
            "type": "integer",
            "enum": [
              2
            ]
          },
          "error": {
            "type": "string"
          },
          "resource": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "description": {
                "type": "string"
              },
              "mimeType": {
                "type": "string"
              }
            }
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "scheme",
                "network",
                "amount",
                "payTo",
                "maxTimeoutSeconds",
                "asset"
              ],
              "properties": {
                "scheme": {
                  "type": "string",
                  "enum": [
                    "exact"
                  ]
                },
                "network": {
                  "type": "string",
                  "example": "eip155:8453",
                  "description": "CAIP-2 network identifier"
                },
                "amount": {
                  "type": "string",
                  "example": "3000",
                  "description": "Amount in atomic units (USDC has 6 decimals, so 3000 = $0.003)"
                },
                "asset": {
                  "type": "string",
                  "description": "USDC asset identifier for the selected network (ERC-20 contract on EVM or mint address on Solana)"
                },
                "payTo": {
                  "type": "string",
                  "description": "Destination account or address for the selected payment network"
                },
                "maxTimeoutSeconds": {
                  "type": "integer"
                },
                "extra": {
                  "type": "object",
                  "description": "EIP-712 domain info and resource URL"
                }
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetail"
            }
          }
        }
      },
      "InvalidSchema": {
        "description": "Invalid request schema",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetail"
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "Upload exceeds 5 MB limit",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetail"
            }
          }
        }
      },
      "UnsupportedMedia": {
        "description": "Unsupported media type",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetail"
            }
          }
        }
      }
    }
  }
}
