{
  "openapi": "3.1.0",
  "info": {
    "title": "Zero Shot API",
    "version": "1.0.0",
    "summary": "Rewrite text through 996 tested AI writing lenses.",
    "description": "Free lens discovery (catalog, semantic search, smart suggestions), free deterministic communication router (POST /v1/agent/route), free x402 try-before-you-buy sandbox (POST /v1/agent/try), dynamic SVG badges (GET /badge), RFC 9728 OAuth 2.1 + DCR discovery, and a remote Streamable HTTP MCP server at https://api.zeroshot.now/mcp with free tools (audit_draft, verify_fidelity, list_lenses, search_lenses, suggest_lenses), freemium optimize_prompt, paid transform_text (with includeDiff: true verified-fact token diffs, x402 USDC or Zero Shot credits; $0 charged if fidelity fails), native MCP resources (zeroshot://lenses/{lensId}), completions, and 50+ prompts. Install the local zs CLI with `curl -fsSL https://zeroshot.now/install.sh | ZEROSHOT_CLI_ONLY=1 sh`.",
    "contact": { "name": "Zero Shot", "url": "https://zeroshot.now" },
    "termsOfService": "https://zeroshot.now/terms",
    "x-logo": { "url": "https://zeroshot.now/logo-512.png" }
  },
  "externalDocs": { "description": "AI-readable site summary", "url": "https://zeroshot.now/llms.txt" },
  "servers": [{ "url": "https://api.zeroshot.now" }],
  "tags": [
    { "name": "Discovery", "description": "Free lens catalog, search, routing and suggestions." },
    { "name": "MCP", "description": "Remote Streamable HTTP MCP endpoint with resources, completions, 50+ prompts, free audit/fidelity/prompt-audit tools and paid transforms." },
    { "name": "Agent transforms", "description": "Free try-before-you-buy sandbox (/v1/agent/try) and pay-per-call x402 v2 (USDC) or Zero Shot credits." },
    { "name": "Badges", "description": "Dynamic Shields-style SVG badges for repos, lenses, and live GitHub README clarity scores." },
    { "name": "OAuth", "description": "RFC 9728 / RFC 8414 / RFC 7591 OAuth 2.1 PKCE discovery and dynamic client registration." }
  ],
  "paths": {
    "/lenses": {
      "get": {
        "operationId": "listLenses",
        "tags": ["Discovery"],
        "summary": "List the public lens catalog (free)",
        "description": "Returns every active lens with its id, label, category and description. Cached at the edge for one hour.",
        "security": [],
        "responses": {
          "200": {
            "description": "Lens catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "lenses": { "type": "array", "items": { "$ref": "#/components/schemas/Lens" } },
                    "count": { "type": "integer" }
                  },
                  "required": ["lenses"]
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/search-lenses": {
      "post": {
        "operationId": "searchLenses",
        "tags": ["Discovery"],
        "summary": "Semantic lens search (free)",
        "description": "Vector search across all 996 lenses. Describe the rewrite you want; returns lens ids with similarity scores, best first.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": { "type": "string", "minLength": 2, "maxLength": 240, "examples": ["cold email to a busy founder"] },
                  "limit": { "type": "integer", "minimum": 1, "maximum": 25, "default": 12 }
                },
                "required": ["query"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Matching lenses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "results": { "type": "array", "items": { "$ref": "#/components/schemas/LensScore" } } },
                  "required": ["results"]
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/suggest-lenses": {
      "post": {
        "operationId": "suggestLenses",
        "tags": ["Discovery"],
        "summary": "Smart lens picks for a draft (free)",
        "description": "Ranks the lenses that best fit a specific draft and says whether the draft is worth rewriting.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": { "type": "string", "minLength": 1, "maxLength": 12000, "examples": ["hey can u send me the deck by friday thx"] },
                  "appContext": { "type": "string", "maxLength": 64, "description": "Destination app, e.g. email, slack, github, linkedin" },
                  "count": { "type": "integer", "minimum": 1, "maximum": 20, "default": 5 }
                },
                "required": ["text"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "suggestions": { "type": "array", "items": { "$ref": "#/components/schemas/LensScore" } },
                    "worth_rewriting": { "type": "boolean" },
                    "worth_rewriting_prob": { "type": "number", "minimum": 0, "maximum": 1 }
                  },
                  "required": ["suggestions"]
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/v1/agent/transform": {
      "post": {
        "operationId": "agentTransform",
        "tags": ["Agent transforms"],
        "summary": "Rewrite text with a lens (paid per call with x402)",
        "description": "Send the request without payment to receive an HTTP 402 with a base64 PAYMENT-REQUIRED header (x402 v2 PaymentRequired). Sign it with an x402 wallet and retry with PAYMENT-SIGNATURE. Settlement happens only after a successful rewrite: model failures and fidelity rejections (422) are not charged. Reuse Idempotency-Key on retries so a rewrite is paid at most once.",
        "security": [],
        "x-payment-info": {
          "protocol": "x402",
          "x402Version": 2,
          "scheme": "exact",
          "networks": ["eip155:84532", "eip155:8453"],
          "asset": "USDC",
          "sandboxUrl": "https://api.zeroshot.now/v1/agent/try",
          "pricing": "Per call, standard and long-text tiers. The 402 challenge is authoritative.",
          "challengeHeader": "PAYMENT-REQUIRED",
          "paymentHeader": "PAYMENT-SIGNATURE",
          "receiptHeader": "PAYMENT-RESPONSE",
          "chargedOnlyOnSuccess": true
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "Base64 x402 v2 PaymentPayload signed for one of the accepted payment requirements.",
            "schema": { "type": "string" }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Client-chosen key (8-128 chars). Retries with the same key and body never pay twice.",
            "schema": { "type": "string", "pattern": "^[A-Za-z0-9_.:-]{8,128}$" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": { "type": "string", "minLength": 1, "maxLength": 12000 },
                  "lensId": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$", "description": "Lens id from /suggest-lenses, /search-lenses or /lenses" },
                  "includeDiff": { "type": "boolean", "description": "Optional. When true, returns token-level diff summary, factsVerified list, fidelity report, and tryOnlineUrl." }
                },
                "required": ["text", "lensId"]
              },
              "examples": {
                "diplomat": { "value": { "text": "idk tell bob we cant do friday", "lensId": "diplomat" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rewritten text. Paid and settled.",
            "headers": {
              "PAYMENT-RESPONSE": { "description": "Base64 x402 settlement response (transaction hash, network, payer).", "schema": { "type": "string" } },
              "X-ZeroShot-Cost-Usd": { "description": "USD charged for this call.", "schema": { "type": "string" } },
              "X-ZeroShot-Payment-Method": { "description": "x402 or credits.", "schema": { "type": "string" } },
              "X-ZeroShot-Tx-Hash": { "description": "Settlement transaction hash.", "schema": { "type": "string" } },
              "X-ZeroShot-Fidelity-Passed": { "description": "Whether the rewrite passed the fidelity check.", "schema": { "type": "string", "enum": ["true", "false"] } }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "text": { "type": "string", "description": "The rewritten text" } },
                  "required": ["text"]
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "402": {
            "description": "Payment required. The PAYMENT-REQUIRED header (base64 JSON) carries the x402 v2 PaymentRequired object and WWW-Authenticate points to OAuth 2.1 protected resource metadata.",
            "headers": {
              "PAYMENT-REQUIRED": { "description": "Base64-encoded x402 v2 PaymentRequired.", "schema": { "type": "string" } },
              "WWW-Authenticate": { "description": "RFC 9728 Bearer resource_metadata challenge.", "schema": { "type": "string" } }
            },
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/PaymentRequired" } }
            }
          },
          "409": { "description": "Idempotency-Key reused with a different body, or the same request is still in progress.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "422": { "description": "Fidelity check rejected the rewrite. Not charged.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpStreamableHttp",
        "tags": ["MCP"],
        "summary": "Remote Streamable HTTP MCP server (2026-07-28 & 2025-11-25)",
        "description": "Stateless Streamable HTTP Model Context Protocol endpoint at https://api.zeroshot.now/mcp. Exposes free zero-auth tools: audit_draft (AI-slop, tone risk, clarity score, lens recommendations), verify_fidelity (deterministic zero-LLM fact-preservation diff), list_lenses, search_lenses, and suggest_lenses; freemium optimize_prompt (always runs a free pre-flight prompt quality audit; runs the promptcraft lens rewrite directly when Bearer auth or x402 payment is provided); paid transform_text (x402 USDC or Zero Shot credits; $0 charged on fidelity failure); and native MCP prompts (optimize_prompt, diplomat, pr_description, concise, de_slop).",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": { "type": "string", "const": "2.0" },
                  "id": { "type": ["string", "integer", "null"] },
                  "method": {
                    "type": "string",
                    "examples": ["tools/list", "tools/call", "prompts/list", "prompts/get"]
                  },
                  "params": { "type": "object" }
                },
                "required": ["jsonrpc", "method"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 MCP response."
          },
          "413": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    },
    "/v1/agent/try": {
      "post": {
        "operationId": "agentTrySandbox",
        "tags": ["Agent transforms"],
        "summary": "Free x402 try-before-you-buy sandbox (3 tries/day/IP, <=400 chars, calibrated lenses)",
        "description": "Test Zero Shot rewrites with zero auth and zero payment on calibrated safe lenses up to 400 characters (3 tries/day/IP). Returns the rewritten text, fidelity verification, optional includeDiff output, and remaining daily quota.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": { "type": "string", "minLength": 1, "maxLength": 400 },
                  "lensId": { "type": "string", "description": "Calibrated safe lens id (e.g. diplomat, concise, polish, suit)." },
                  "includeDiff": { "type": "boolean" }
                },
                "required": ["text", "lensId"]
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Free sandbox rewrite with fidelity verification and remaining daily quota." },
          "404": { "description": "Lens not eligible for sandbox." },
          "413": { "description": "Text exceeds 400-character sandbox limit." },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/v1/agent/route": {
      "post": {
        "operationId": "agentRouteCommunication",
        "tags": ["Discovery"],
        "summary": "Free deterministic communication router (<120ms, zero auth)",
        "description": "Fast, zero-auth, zero-LLM router that audits a draft and returns { shouldRewrite, lensId, confidence, estimatedCostUsd, transformEndpoint, sandboxEndpoint, audit }.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": { "type": "string", "minLength": 1, "maxLength": 12000 },
                  "channel": { "type": "string", "maxLength": 64, "examples": ["email", "slack", "github"] },
                  "audience": { "type": "string", "maxLength": 120, "examples": ["executive", "customer", "team"] },
                  "goal": { "type": "string", "maxLength": 160, "examples": ["soften", "shorten", "pr description"] }
                },
                "required": ["text"]
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Deterministic routing recommendation and full draft audit." },
          "400": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    },
    "/badge": {
      "get": {
        "operationId": "getBadge",
        "tags": ["Badges"],
        "summary": "Dynamic flat SVG badges (ZeroShot | 996 lenses, ?lens=<id>, /badge/:kind.svg, /badge/readme/:owner/:repo.svg)",
        "description": "Serves crisp Shields-style SVG badges cached at the edge, including live GitHub README Clarity score badges at /badge/readme/{owner}/{repo}.svg.",
        "security": [],
        "parameters": [
          { "name": "lens", "in": "query", "required": false, "schema": { "type": "string" } },
          { "name": "kind", "in": "query", "required": false, "schema": { "type": "string", "enum": ["lenses", "mcp", "x402", "fidelity"] } },
          { "name": "color", "in": "query", "required": false, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "SVG badge image.",
            "content": { "image/svg+xml": { "schema": { "type": "string" } } }
          }
        }
      }
    },
    "/oauth/register": {
      "post": {
        "operationId": "oauthDynamicClientRegistration",
        "tags": ["OAuth"],
        "summary": "RFC 7591 dynamic client registration for public PKCE MCP clients",
        "security": [],
        "responses": {
          "201": { "description": "Registered public PKCE client_id." },
          "400": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    },
    "/oauth/authorize": {
      "get": {
        "operationId": "oauthAuthorize",
        "tags": ["OAuth"],
        "summary": "OAuth 2.1 authorization redirect to Zero Shot sign-in",
        "security": [],
        "responses": {
          "302": { "description": "Redirects to https://zeroshot.now/desktop-auth or https://zeroshot.now/setup." }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Lens": {
        "type": "object",
        "properties": {
          "lens_id": { "type": "string" },
          "label": { "type": "string" },
          "category": { "type": "string" },
          "description": { "type": "string" },
          "tags": { "type": "array", "items": { "type": "string" } }
        },
        "required": ["lens_id"]
      },
      "LensScore": {
        "type": "object",
        "properties": {
          "lens_id": { "type": "string" },
          "score": { "type": "number" }
        },
        "required": ["lens_id"]
      },
      "PaymentRequirements": {
        "type": "object",
        "properties": {
          "scheme": { "type": "string", "examples": ["exact"] },
          "network": { "type": "string", "description": "CAIP-2 chain id", "examples": ["eip155:8453"] },
          "amount": { "type": "string", "description": "Atomic units (USDC has 6 decimals)" },
          "asset": { "type": "string", "description": "Token contract address" },
          "payTo": { "type": "string" },
          "maxTimeoutSeconds": { "type": "integer" },
          "extra": { "type": "object" }
        },
        "required": ["scheme", "network", "amount", "asset", "payTo", "maxTimeoutSeconds"]
      },
      "PaymentRequired": {
        "type": "object",
        "properties": {
          "x402Version": { "type": "integer", "const": 2 },
          "error": { "type": "string" },
          "resource": {
            "type": "object",
            "properties": {
              "url": { "type": "string", "format": "uri" },
              "description": { "type": "string" },
              "mimeType": { "type": "string" },
              "serviceName": { "type": "string" },
              "tags": { "type": "array", "items": { "type": "string" } }
            },
            "required": ["url"]
          },
          "accepts": { "type": "array", "items": { "$ref": "#/components/schemas/PaymentRequirements" } },
          "extensions": { "type": "object" }
        },
        "required": ["x402Version", "resource", "accepts"]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "code": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request body.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "RateLimited": {
        "description": "Rate limited. Retry after the Retry-After header.",
        "headers": { "Retry-After": { "schema": { "type": "integer" } } },
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    }
  }
}
