{
  "openapi": "3.1.0",
  "info": {
    "title": "Humanshot GEO Probe API",
    "version": "1.0.0",
    "description": "Capture answers and available sources from the ChatGPT website in a browser in the selected region. Use GEO Probe to compare what ChatGPT surfaces across regions. Answers and citations from the OpenAI API may differ for the same question.",
    "x-guidance": "Regional answers and available sources from the ChatGPT website. POST /v1/chat accepts a JSON prompt and optional region (KR, JP, or US), sessionId, and timeoutSeconds. Unsigned requests receive x402 payment terms."
  },
  "servers": [
    {
      "url": "https://humanshot.dev"
    }
  ],
  "externalDocs": {
    "description": "API documentation",
    "url": "https://humanshot.dev/en/#api"
  },
  "tags": [
    {
      "name": "Discovery",
      "description": "Gateway liveness and supported regions."
    },
    {
      "name": "Chat",
      "description": "Regional searches, x402 payment, and continuation."
    },
    {
      "name": "Sessions",
      "description": "Manage sessions owned by approved Google callers."
    },
    {
      "name": "Browser demo",
      "description": "Turnstile-gated comparisons from the Humanshot website."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "Discovery"
        ],
        "summary": "Check gateway liveness",
        "description": "Checks that the gateway can answer HTTP requests.",
        "security": [],
        "responses": {
          "200": {
            "description": "The gateway is running.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/regions": {
      "get": {
        "operationId": "listRegions",
        "tags": [
          "Discovery"
        ],
        "summary": "List supported region codes",
        "security": [],
        "responses": {
          "200": {
            "description": "Supported region codes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "regions"
                  ],
                  "properties": {
                    "regions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Region"
                      },
                      "examples": [
                        [
                          "KR",
                          "JP",
                          "US"
                        ]
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat": {
      "post": {
        "operationId": "runChat",
        "tags": [
          "Chat"
        ],
        "summary": "Run a search or continue a session",
        "description": "GEO Probe submits the question to the ChatGPT website in a browser and captures the response for that session.\n\nChoose Seoul (KR), Tokyo (JP), or Oregon (US) in the JSON body. New sessions default to KR. To continue, use the session identifier returned to the same caller and omit the region or supply the original one.\n\nPublic calls use x402 v2 exact with upfront settlement on Solana mainnet. The price is 0.06 native USDC per search. Start with an unsigned request to receive a 402 response and read the base64-encoded JSON in PAYMENT-REQUIRED. To inspect pricing without running a search, send an unsigned empty JSON object. For a search, start with the complete search body and retry that body with PAYMENT-SIGNATURE. Settlement precedes search execution. PAYMENT-RESPONSE conveys the settlement receipt and may accompany an error after payment.\n\nFor retries of the same paid request, retain the original body and the exact PAYMENT-SIGNATURE value. A request still running can return 409. An x402 follow-up uses the same paying wallet and a new payment.\n\nApproved Google service accounts can use a Google ID token with audience https://humanshot.dev in the Authorization: Bearer header. If Authorization is present, the gateway uses Google identity authentication.",
        "x-probe-body": {},
        "security": [
          {
            "GoogleIdToken": []
          },
          {
            "X402PaymentSignature": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "description": "JSON request body. Maximum size is 64 KiB.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              },
              "examples": {
                "quote": {
                  "summary": "Start a new search. Send without authorization or a payment signature to get a quote.",
                  "value": {
                    "prompt": "What are the national holidays in Japan? Cite your sources.",
                    "region": "JP"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search completed. An x402 request includes a settlement receipt.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, prompt, region, session ID, or timeout. This also covers a request rejected by the regional worker.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The provided Google ID token is invalid (invalid_token), or Google authentication is required when x402 is unavailable (authentication_required).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "A payment is required, invalid, or rejected (payment_required, invalid_payment, or settlement_rejected). PAYMENT-REQUIRED is the canonical source for the offered terms. The JSON body also includes the quote for catalogs and inspection.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PaymentRequired"
              },
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    { "$ref": "#/components/schemas/Error" },
                    { "$ref": "#/components/schemas/PaymentQuote" }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The Google identity is valid and its subject is unapproved (access_denied).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The session does not exist or belongs to another caller (session_not_found).",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Session region mismatch, concurrent session operation, duplicate payment proof for a different request, or payment processing still underway.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              },
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds 64 KiB (body_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "The request does not have Content-Type: application/json (content_type).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The gateway failed to complete the request (gateway_error).",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The regional worker failed or returned an invalid response.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Payment terms are unavailable or settlement could not be confirmed (facilitator_unavailable or settlement_pending). A receipt or transaction reference may be available in PAYMENT-RESPONSE.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "$ref": "#/components/headers/PaymentResponse"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.06"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/v1/sessions/{sessionId}": {
      "parameters": [
        {
          "name": "sessionId",
          "in": "path",
          "required": true,
          "description": "The UUID v4 returned in ChatResult. The authenticated Google caller must own the session.",
          "schema": {
            "$ref": "#/components/schemas/SessionId"
          }
        }
      ],
      "get": {
        "operationId": "getSession",
        "tags": [
          "Sessions"
        ],
        "summary": "Read session metadata and turns",
        "security": [
          {
            "GoogleIdToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The authenticated caller’s session details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "The regional worker rejected the session request (worker_rejected_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "A Google ID token is missing or invalid (authentication_required or invalid_token).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The Google identity is valid and its subject is unapproved (access_denied).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The session or route is unavailable to this caller (session_not_found or not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Another request is using this session (session_busy).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The gateway failed to complete the request (gateway_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The regional worker failed or returned an unreadable response (worker_failed, body_too_large, or invalid_json).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteSession",
        "tags": [
          "Sessions"
        ],
        "summary": "Delete a caller-owned session",
        "security": [
          {
            "GoogleIdToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The session was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "$ref": "#/components/schemas/SessionId"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The regional worker rejected the session request (worker_rejected_request).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "A Google ID token is missing or invalid (authentication_required or invalid_token).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The Google identity is valid and its subject is unapproved (access_denied).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The session or route is unavailable to this caller (session_not_found or not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Another request is using this session (session_busy).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The gateway failed to complete the request (gateway_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The regional worker failed or returned an unreadable response (worker_failed, body_too_large, or invalid_json).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/demo/config": {
      "get": {
        "operationId": "getDemoConfig",
        "tags": [
          "Browser demo"
        ],
        "summary": "Get browser demo configuration",
        "description": "Check availability before rendering the first-party form. Enabled responses provide the public Turnstile site key and widget action for this origin.",
        "security": [],
        "responses": {
          "200": {
            "description": "Browser configuration or an explicit disabled state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoConfig"
                },
                "examples": {
                  "disabled": {
                    "value": {
                      "enabled": false
                    }
                  },
                  "enabled": {
                    "value": {
                      "enabled": true,
                      "siteKey": "<site key from live configuration>",
                      "action": "geo_demo"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/demo": {
      "post": {
        "operationId": "runBrowserDemo",
        "tags": [
          "Browser demo"
        ],
        "summary": "Compare a prompt across three regions",
        "description": "Obtain a fresh token from the Humanshot Turnstile widget using GET /v1/demo/config. Each accepted submission consumes one slot from the shared UTC daily allowance and sends the question to the ChatGPT website from KR, JP, and US concurrently. For general API access, use POST /v1/chat.",
        "security": [],
        "requestBody": {
          "required": true,
          "description": "JSON request body. Maximum size is 64 KiB.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "UTF-8 newline-delimited JSON. A completed stream emits one result or error for each region in completion order, then a done line. A regional error is carried inside the stream.",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string",
                  "description": "Split on newlines and parse each complete line as JSON. Result lines have type, region, answer, and sources. Error lines have type, region, and code (worker_failed or worker_timeout). The final line is {\"type\":\"done\"}."
                },
                "x-ndjson-line-schema": {
                  "title": "DemoStreamEvent",
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "region",
                        "answer",
                        "sources"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "result"
                        },
                        "region": {
                          "$ref": "#/components/schemas/Region"
                        },
                        "answer": {
                          "type": "string"
                        },
                        "sources": {
                          "type": "array",
                          "description": "Deduplicated HTTP or HTTPS sources.",
                          "items": {
                            "type": "object",
                            "required": [
                              "title",
                              "url"
                            ],
                            "properties": {
                              "title": {
                                "type": "string"
                              },
                              "url": {
                                "type": "string",
                                "format": "uri"
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "type",
                        "region",
                        "code"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "error"
                        },
                        "region": {
                          "$ref": "#/components/schemas/Region"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "worker_failed",
                            "worker_timeout"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "type"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "done"
                        }
                      }
                    }
                  ]
                },
                "example": "{\"type\":\"result\",\"region\":\"JP\",\"answer\":\"An example regional answer.\",\"sources\":[{\"title\":\"Example source\",\"url\":\"https://example.org/\"}]}\n{\"type\":\"error\",\"region\":\"US\",\"code\":\"worker_timeout\"}\n{\"type\":\"result\",\"region\":\"KR\",\"answer\":\"Another example regional answer.\",\"sources\":[]}\n{\"type\":\"done\"}\n"
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid prompt, or invalid Turnstile token syntax (invalid_json, invalid_prompt, or invalid_turnstile_token).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Turnstile verification failed. Expired, invalid, duplicate, or replayed tokens and hostname or action mismatches return turnstile_failed. Obtain a fresh token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The browser demo is disabled (demo_disabled).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The request body exceeds 64 KiB (body_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "The request does not have Content-Type: application/json (content_type).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "The shared daily demo allowance is exhausted (demo_limit_reached).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "required": true,
                "description": "Seconds until the allowance resets at the next UTC midnight.",
                "schema": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 86400
                }
              }
            }
          },
          "500": {
            "description": "The gateway failed to complete the request (gateway_error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Browser verification or the daily allowance service is temporarily unavailable (demo_unavailable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "GoogleIdToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Google ID token (JWT)",
        "description": "Google-issued identity token with audience https://humanshot.dev. The gateway verifies the audience and an approved subject."
      },
      "X402PaymentSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "Base64 JSON x402 v2 payment payload populated by an x402 client from the live quote, including the signed Solana transaction. Send with the original request body."
      }
    },
    "headers": {
      "PaymentRequired": {
        "description": "x402 v2 quote. Decode the header and use its live payment requirements, recipient, and fee payer to construct the signed payment.",
        "schema": {
          "type": "string",
          "contentEncoding": "base64",
          "contentMediaType": "application/json",
          "contentSchema": {
            "$ref": "#/components/schemas/PaymentQuote"
          }
        }
      },
      "PaymentResponse": {
        "description": "x402 settlement receipt when available. A failure after settlement can still include a confirmed receipt.",
        "schema": {
          "type": "string",
          "contentEncoding": "base64",
          "contentMediaType": "application/json",
          "contentSchema": {
            "$ref": "#/components/schemas/PaymentReceipt"
          }
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying the same request when payment processing is still underway.",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "examples": [
            10
          ]
        }
      }
    },
    "schemas": {
      "Region": {
        "type": "string",
        "enum": [
          "KR",
          "JP",
          "US"
        ],
        "description": "KR is Seoul, South Korea. JP is Tokyo, Japan. US is Oregon, United States."
      },
      "SessionId": {
        "type": "string",
        "format": "uuid",
        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89aAbB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
      },
      "ChatRequest": {
        "type": "object",
        "required": [
          "prompt"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S",
            "description": "A question or search task containing at least one non-whitespace character."
          },
          "region": {
            "type": "string",
            "pattern": "^(?:[kK][rR]|[jJ][pP]|[uU][sS])$",
            "examples": [
              "JP"
            ],
            "description": "Case-insensitive KR, JP, or US. A new session defaults to KR. A continued session defaults to its original region."
          },
          "sessionId": {
            "$ref": "#/components/schemas/SessionId",
            "description": "Omit this field for a new search. To continue, use the session ID previously returned to this caller."
          },
          "timeoutSeconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 280,
            "default": 280,
            "description": "Search execution timeout in seconds."
          }
        }
      },
      "ChatResult": {
        "type": "object",
        "required": [
          "sessionId",
          "region",
          "answer"
        ],
        "properties": {
          "sessionId": {
            "$ref": "#/components/schemas/SessionId",
            "examples": [
              "7e896ba7-e4bc-4675-915e-efbc5c50ac14"
            ]
          },
          "region": {
            "$ref": "#/components/schemas/Region"
          },
          "browser": {
            "type": "object",
            "required": [
              "locale",
              "timezoneId"
            ],
            "properties": {
              "locale": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "timezoneId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "continuation": {
            "$ref": "#/components/schemas/Continuation"
          },
          "conversationId": {
            "type": "string"
          },
          "userMessageCount": {
            "type": "integer",
            "minimum": 1
          },
          "answer": {
            "type": "string",
            "description": "Search answer, which may contain Markdown."
          },
          "sources": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Sources"
              },
              {
                "type": "null"
              }
            ],
            "description": "Available references, or null when the response format does not carry source metadata."
          },
          "cost": {
            "$ref": "#/components/schemas/CostEstimate"
          }
        }
      },
      "Continuation": {
        "type": "string",
        "enum": [
          "new",
          "revived",
          "original-tab"
        ]
      },
      "Sources": {
        "type": "object",
        "required": [
          "activity",
          "searchResults",
          "citations",
          "links"
        ],
        "properties": {
          "activity": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "searchResults": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "url",
                "title",
                "domain"
              ],
              "properties": {
                "url": {
                  "type": "string"
                },
                "title": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "domain": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "refId",
                "refTypes",
                "url",
                "title",
                "sourceName",
                "label"
              ],
              "properties": {
                "refId": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "refTypes": {
                  "type": "array",
                  "items": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "url": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "title": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "sourceName": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "label": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "url",
                "title"
              ],
              "properties": {
                "url": {
                  "type": "string"
                },
                "title": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "CostEstimate": {
        "type": "object",
        "required": [
          "stage"
        ],
        "properties": {
          "stage": {
            "type": "string",
            "const": "before-send"
          },
          "currency": {
            "type": "string",
            "const": "USD"
          },
          "totalUsd": {
            "type": "number",
            "minimum": 0
          },
          "usage": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "minimum": 0
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item": {
                  "type": "string"
                },
                "sku": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number",
                  "minimum": 0
                },
                "unit": {
                  "type": "string"
                },
                "unitPriceUsd": {
                  "type": "number",
                  "minimum": 0
                },
                "usd": {
                  "type": "number",
                  "minimum": 0
                }
              }
            }
          },
          "pricing": {
            "type": "object",
            "properties": {
              "region": {
                "type": "string"
              },
              "fetchedAt": {
                "type": "string"
              },
              "source": {
                "type": "string"
              }
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "description": "Estimated processing resource cost. The x402 quote specifies the payment amount. If estimates are unavailable, only stage is returned."
      },
      "Session": {
        "type": "object",
        "required": [
          "id",
          "region",
          "createdAt",
          "updatedAt",
          "turns"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/SessionId"
          },
          "region": {
            "$ref": "#/components/schemas/Region"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "turns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SessionTurn"
            }
          }
        }
      },
      "SessionTurn": {
        "type": "object",
        "required": [
          "at",
          "continuation",
          "prompt",
          "answer",
          "conversationId"
        ],
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "continuation": {
            "$ref": "#/components/schemas/Continuation"
          },
          "prompt": {
            "type": "string"
          },
          "answer": {
            "type": "string"
          },
          "conversationId": {
            "type": "string"
          },
          "assistantMessageId": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error."
          },
          "code": {
            "type": [
              "string",
              "integer"
            ],
            "description": "Machine-readable gateway or upstream error code."
          }
        }
      },
      "PaymentQuote": {
        "type": "object",
        "required": [
          "x402Version",
          "resource",
          "accepts"
        ],
        "properties": {
          "x402Version": {
            "type": "integer",
            "const": 2
          },
          "error": {
            "type": "string"
          },
          "resource": {
            "type": "object",
            "required": [
              "url"
            ],
            "properties": {
              "url": {
                "type": "string",
                "const": "https://humanshot.dev/v1/chat"
              },
              "description": {
                "type": "string"
              },
              "mimeType": {
                "type": "string"
              }
            }
          },
          "accepts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SolanaPaymentRequirement"
            },
            "minItems": 1
          }
        },
        "description": "Decoded PAYMENT-REQUIRED example. The address placeholders illustrate fields. Use the live quote for every actual payment.",
        "examples": [
          {
            "x402Version": 2,
            "error": "Payment is required.",
            "resource": {
              "url": "https://humanshot.dev/v1/chat",
              "description": "Run a GEO search",
              "mimeType": "application/json"
            },
            "accepts": [
              {
                "scheme": "exact",
                "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
                "amount": "60000",
                "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                "payTo": "<recipient from live quote>",
                "maxTimeoutSeconds": 60,
                "extra": {
                  "feePayer": "<fee payer from live quote>",
                  "paymentFlow": "upfront"
                }
              }
            ]
          }
        ]
      },
      "SolanaPaymentRequirement": {
        "type": "object",
        "required": [
          "scheme",
          "network",
          "amount",
          "asset",
          "payTo",
          "maxTimeoutSeconds",
          "extra"
        ],
        "properties": {
          "scheme": {
            "type": "string",
            "const": "exact"
          },
          "network": {
            "type": "string",
            "const": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
          },
          "amount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "examples": [
              "60000"
            ],
            "description": "Atomic units of native USDC. At six decimals, 60000 equals 0.06 USDC."
          },
          "asset": {
            "type": "string",
            "const": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
            "description": "Native USDC mint on Solana mainnet."
          },
          "payTo": {
            "type": "string",
            "description": "The Solana recipient address from the live quote."
          },
          "maxTimeoutSeconds": {
            "type": "integer",
            "minimum": 1,
            "examples": [
              60
            ],
            "description": "Payment timeout in seconds, independent of the search execution timeout."
          },
          "extra": {
            "type": "object",
            "required": [
              "feePayer",
              "paymentFlow"
            ],
            "properties": {
              "feePayer": {
                "type": "string",
                "description": "Solana fee payer advertised by the facilitator."
              },
              "paymentFlow": {
                "type": "string",
                "const": "upfront"
              }
            }
          }
        }
      },
      "PaymentReceipt": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "network": {
            "type": "string"
          },
          "transaction": {
            "type": "string",
            "description": "Solana transaction signature when available."
          },
          "payer": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "errorReason": {
            "type": "string"
          }
        }
      },
      "DemoConfig": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "enabled"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "const": false
              }
            }
          },
          {
            "type": "object",
            "required": [
              "enabled",
              "siteKey",
              "action"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "const": true
              },
              "siteKey": {
                "type": "string",
                "description": "The public Turnstile widget site key."
              },
              "action": {
                "type": "string",
                "const": "geo_demo"
              }
            }
          }
        ]
      },
      "DemoRequest": {
        "type": "object",
        "required": [
          "prompt",
          "turnstileToken"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S",
            "description": "A prompt of 1 to 300 Unicode code points after trimming whitespace."
          },
          "turnstileToken": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "pattern": "^\\S+$",
            "description": "A fresh, single-use token from the Humanshot Turnstile widget configured with action geo_demo."
          }
        }
      }
    }
  }
}
