{
  "openapi": "3.1.0",
  "info": {
    "title": "StealthGPT API",
    "description": "Generate or rephrase content to be undetectable by AI detection tools",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://www.stealthgpt.ai"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api/stealthify": {
      "post": {
        "summary": "Generate or rephrase content",
        "description": "This endpoint allows you to generate new content based on a prompt or rephrase existing text to be undetectable by AI detection tools.",
        "parameters": [
          {
            "name": "idempotency-key",
            "in": "header",
            "description": "Optional key, 1-255 characters. Only used when a text over 1,500 words is humanized as an async run (rephrase true, model super or standard): the same request sent again with the same key gets that run back instead of starting a new one. A run that failed stays failed under its key.",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthifyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthifyResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted - a text over 1,500 words with rephrase true and model super or standard runs as an async run, and it was still running when the request stopped waiting for it. Poll statusUrl with the same api-token until the run is completed, failed or cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StealthifyApiCreateRunResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "description": "How to collect the result."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - not enough prepaid words, no API plan, payment method not set up, or pay-as-you-go terms not accepted (legacy accounts)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/balance": {
      "get": {
        "summary": "Check account balance",
        "description": "This endpoint allows you to check your current account balance and available words without making any content generation requests.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/detect": {
      "post": {
        "summary": "Detect AI-generated text",
        "description": "Run an AI-detection check on a piece of text using GPTZero. Returns a 0-100 score indicating how likely the text is to be flagged as AI-generated.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DetectRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetectResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid parameters or text exceeds the 50,000 character limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - not enough prepaid words, no API plan, payment method not set up, or pay-as-you-go terms not accepted (legacy accounts)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable - the detector could not score the text. The request is not charged; retry after a short wait.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/agent": {
      "post": {
        "summary": "Run Stealth Agent and wait for the result",
        "description": "Runs a Stealth Agent pipeline (research, generation, humanization, optional fact-check and images) and returns the finished document. Requests can take several minutes, so use a client timeout of at least 10 minutes, or the async POST /api/stealthify/agent/runs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthAgentApiGenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthAgentApiGenerateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - insufficient credits, no API plan, pay-as-you-go unavailable, payment method missing, or billing cap delay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "499": {
            "description": "Request aborted - the client disconnected or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/agent/runs": {
      "post": {
        "summary": "Create an async Stealth Agent run",
        "description": "Queues a long-running Stealth Agent generation job and returns immediately with a run id for polling or webhook reconciliation.",
        "parameters": [
          {
            "name": "idempotency-key",
            "in": "header",
            "description": "Optional key, 1-255 characters. Reuse the same key when retrying the same create request to avoid enqueueing duplicate runs.",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthAgentApiCreateRunRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Run queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthAgentApiCreateRunResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid body or idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - insufficient credits, no API plan, pay-as-you-go unavailable, payment method missing, or billing cap delay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/agent/runs/{runId}": {
      "get": {
        "summary": "Get async Stealth Agent run status",
        "description": "Returns the current status for an async Stealth Agent run. Terminal responses use the same payload shape as webhook callbacks.",
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "description": "Run id returned by POST /api/stealthify/agent/runs.",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current run status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthAgentApiRunStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid run id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Run not found or belongs to another account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/runs": {
      "post": {
        "summary": "Create an async writer or humanizer run",
        "description": "Queues an async writer or humanizer job and returns immediately with a run id for polling or webhook reconciliation. rephrase true (default) humanizes existing text. rephrase false writes new content from the prompt, then humanizes that draft. Send text as JSON, or upload a PDF/DOCX/TXT/MD file as multipart/form-data; the result is always returned as text.",
        "parameters": [
          {
            "name": "idempotency-key",
            "in": "header",
            "description": "Optional key, 1-255 characters. Reuse the same key when retrying the same create request to avoid enqueueing duplicate runs.",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthifyApiCreateRunRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/StealthifyApiCreateRunFileRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Run queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthifyApiCreateRunResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid body, idempotency key, or uploaded file (unsupported type, over 4MB, empty, or no readable text)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - insufficient credits, no API plan, pay-as-you-go unavailable, or payment method missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/runs/bulk": {
      "post": {
        "summary": "Create async writer or humanizer runs in bulk",
        "description": "Queues up to 100 async runs in one request. Each item is a POST /api/stealthify/runs JSON body and becomes its own run, with its own run id, status and webhook. The batch is checked against the balance as a whole, using an estimate: if it can't be covered, nothing is queued. Each run is billed when it finishes. One batch per account runs at a time: while the previous one has runs queued or running, a new request gets 409. The request body can be at most 4.5 MB.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthifyApiCreateBulkRunsRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Runs queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthifyApiCreateBulkRunsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid body; info lists each issue with its path, such as items.3.model. Nothing is queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required - the balance or pay-as-you-go can't cover the estimate for the whole batch, no API plan, or payment method missing. Nothing is queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The previous batch still has runs queued or running. Send the next batch when it finishes. Nothing is queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Request body over 4.5 MB. Send fewer items per request. Nothing is queued."
          },
          "429": {
            "description": "Too many runs queued at once. Wait the seconds in the Retry-After header and send the same request again. Items without an idempotencyKey may already have started, and sending them again queues them again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Send the same request again: items with an idempotencyKey come back as the runs they already started, while items without one may already have started and are queued again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/stealthify/runs/{runId}": {
      "get": {
        "summary": "Get async humanization run status",
        "description": "Returns the current status for an async humanization run. Terminal responses use the same payload shape as webhook callbacks.",
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "description": "Run id returned by POST /api/stealthify/runs.",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current run status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StealthifyApiRunStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid run id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Run not found or belongs to another account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "stealthAgentRunCallback": {
      "post": {
        "summary": "Stealth Agent run completion callback",
        "description": "Sent to the `webhookUrl` provided on run creation when an async Stealth Agent run reaches a terminal status. When `webhookSecret` was provided, the request is signed with HMAC-SHA256 over `${x-stealthgpt-timestamp}.${rawBody}`.",
        "parameters": [
          {
            "name": "x-stealthgpt-event",
            "in": "header",
            "schema": {
              "type": "string",
              "enum": [
                "stealth_agent.run.completed",
                "stealth_agent.run.failed",
                "stealth_agent.run.cancelled"
              ]
            }
          },
          {
            "name": "x-stealthgpt-run-id",
            "in": "header",
            "schema": { "type": "string" }
          },
          {
            "name": "x-stealthgpt-timestamp",
            "in": "header",
            "schema": { "type": "string" }
          },
          {
            "name": "x-stealthgpt-signature",
            "in": "header",
            "description": "Present when a webhookSecret was supplied. Format: `v1={hex_hmac_sha256}`.",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthAgentApiRunStatusResponse"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx (429/5xx) responses are retried up to 3 times."
          }
        }
      }
    },
    "stealthifyRunCallback": {
      "post": {
        "summary": "Humanization run completion callback",
        "description": "Sent to the `webhookUrl` provided on run creation when an async humanization run reaches a terminal status. When `webhookSecret` was provided, the request is signed with HMAC-SHA256 over `${x-stealthgpt-timestamp}.${rawBody}`.",
        "parameters": [
          {
            "name": "x-stealthgpt-event",
            "in": "header",
            "schema": {
              "type": "string",
              "enum": [
                "stealthify.run.completed",
                "stealthify.run.failed",
                "stealthify.run.cancelled"
              ]
            }
          },
          {
            "name": "x-stealthgpt-run-id",
            "in": "header",
            "schema": { "type": "string" }
          },
          {
            "name": "x-stealthgpt-timestamp",
            "in": "header",
            "schema": { "type": "string" }
          },
          {
            "name": "x-stealthgpt-signature",
            "in": "header",
            "description": "Present when a webhookSecret was supplied. Format: `v1={hex_hmac_sha256}`.",
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StealthifyApiRunStatusResponse"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx (429/5xx) responses are retried up to 3 times."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StealthifyRequest": {
        "type": "object",
        "required": ["prompt", "rephrase", "model"],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "When rephrase is false, the topic or instructions for content generation. When rephrase is true, the existing text to humanize — send only that source text with no instruction wrappers such as 'Humanize the following text' (maximum 3,000 words per request)",
            "minLength": 1
          },
          "rephrase": {
            "type": "boolean",
            "description": "Set to true to rephrase the provided prompt text (prompt must be only the source text, with no instruction wrappers), or false to generate new content based on the prompt"
          },
          "tone": {
            "type": "string",
            "description": "Controls the style and complexity of generated content when writingMode is essay. Ignored in default mode and when rephrase is true.",
            "enum": ["Standard", "HighSchool", "College", "PhD"],
            "default": "College"
          },
          "writingMode": {
            "type": "string",
            "description": "Controls how content is generated when rephrase is false. 'default' follows the user's prompt without forcing essay structure. 'essay' structures the output as an academic essay. Defaults to default.",
            "enum": ["default", "essay"],
            "default": "default"
          },
          "qualityMode": {
            "type": "string",
            "description": "On model 'standard', 'quality' runs quality checks/repairs and 'fast' skips them for a single-pass rewrite; output may have more errors and be more detectable. On 'super', 'quality' removes em dashes from the output and 'fast' keeps them. 'lite' ignores it.",
            "enum": ["fast", "quality"],
            "default": "quality"
          },
          "model": {
            "type": "string",
            "description": "Selects the humanizer model. 'super' is the flagship humanizer billed at $0.05 / 100 words. 'standard' and 'lite' are billed at $0.20 / 1,000 words.",
            "enum": ["super", "standard", "lite"]
          },
          "outputFormat": {
            "type": "string",
            "description": "Controls the formatting of the returned content. When set to 'markdown', the result is formatted with markdown syntax; 'text' returns plain text.",
            "enum": ["text", "markdown"],
            "default": "text"
          },
          "preservation": {
            "type": "boolean",
            "default": false,
            "description": "Keeps every marker such as [[T1]] byte-for-byte and in order while the text around it is humanized. Requires rephrase: true. See https://docs.stealthgpt.ai/api-reference/text-preservation"
          },
          "preservationOpen": {
            "type": "string",
            "default": "[[",
            "minLength": 1,
            "maxLength": 10,
            "description": "Opening delimiter of a marker, no spaces."
          },
          "preservationClose": {
            "type": "string",
            "default": "]]",
            "minLength": 1,
            "maxLength": 10,
            "description": "Closing delimiter of a marker, no spaces. Must differ from preservationOpen."
          },
          "preservationMaxLookahead": {
            "type": "integer",
            "default": 10,
            "minimum": 1,
            "maximum": 64,
            "description": "Most characters allowed between the delimiters. A [[ without a ]] within this many characters is ordinary text."
          },
          "preservationMode": {
            "type": "string",
            "enum": ["inline", "split"],
            "default": "inline",
            "description": "inline rewrites the text in one pass with the markers held in place and falls back to split for any text where a marker moved. split rewrites each stretch between two markers on its own."
          }
        }
      },
      "StealthifyResponse": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "description": "The generated or rephrased content"
          },
          "howLikelyToBeDetected": {
            "type": "number",
            "description": "Human-likeness score from 0 to 100. Higher is better: a higher score means the content reads as more human and is less likely to be flagged as AI; a lower score means it is more likely to be detected as AI-generated. (The field name is historical — treat a higher value as the better result.)"
          },
          "wordsSpent": {
            "type": "number",
            "description": "Words charged for this request. Super is billed at $0.05 / 100 words. standard and lite are billed at $0.20 / 1,000 words."
          },
          "remainingCredits": {
            "type": "number",
            "description": "Prepaid word balance remaining after this request (can be 0 while billingMode is 'payg')."
          },
          "billingMode": {
            "type": "string",
            "description": "Whether this request was billed from prepaid words or pay-as-you-go metered billing",
            "enum": ["prepaid", "payg"]
          },
          "meteredChargedCredits": {
            "type": "number",
            "description": "If billed via pay-as-you-go, words added to metered usage for this request (0 when billed from prepaid)."
          },
          "preservation": {
            "$ref": "#/components/schemas/StealthifyPreservationReport"
          }
        }
      },
      "StealthifyPreservationReport": {
        "type": "object",
        "description": "Present only when the request used preservation.",
        "required": ["frozenCount", "preservedCount", "mode", "fallbackUsed"],
        "properties": {
          "frozenCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Markers found in the input."
          },
          "preservedCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Markers returned unchanged. Always equal to frozenCount in a successful response."
          },
          "mode": {
            "type": "string",
            "enum": ["inline", "split"],
            "description": "The requested preservation mode. fallbackUsed tells you when inline fell back."
          },
          "fallbackUsed": {
            "type": "boolean",
            "description": "In inline mode, true when the text fell back to split. Always false in split mode."
          }
        }
      },
      "DetectRequest": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "description": "The text to analyze for AI-generated content (maximum 50,000 characters per request)",
            "minLength": 1
          }
        }
      },
      "DetectResponse": {
        "type": "object",
        "properties": {
          "howLikelyToBeDetected": {
            "type": "number",
            "description": "A score from 0 to 100 indicating how likely the input text is to be flagged as AI-generated by detection tools (higher means more likely to be flagged)"
          },
          "wordsSpent": {
            "type": "number",
            "description": "Number of words charged for this request (equal to the input word count)"
          },
          "remainingCredits": {
            "type": "number",
            "description": "Number of prepaid words remaining after this request (can be 0 while billingMode is 'payg')"
          },
          "billingMode": {
            "type": "string",
            "description": "Whether this request was billed from prepaid words or pay-as-you-go metered billing",
            "enum": ["prepaid", "payg"]
          },
          "meteredChargedCredits": {
            "type": "number",
            "description": "If billed via pay-as-you-go, the number of words added to metered usage for this request (0 when billed from prepaid)"
          }
        }
      },
      "BalanceResponse": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "number",
            "description": "Number of prepaid words available in your account"
          },
          "payg": {
            "description": "Pay-as-you-go (metered) billing status and any usage pending billing. When null, the account is not enrolled in metered billing.",
            "anyOf": [
              { "$ref": "#/components/schemas/StealthApiPaygStatus" },
              { "type": "null" }
            ]
          }
        }
      },
      "StealthApiPaygStatus": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "description": "Current pay-as-you-go billing mode",
            "enum": [
              "metered_active",
              "metered_past_due",
              "metered_setup_required"
            ]
          },
          "unbilledCredits": {
            "type": "number",
            "description": "Credits accumulated for metered billing that have not yet been flushed to Stripe"
          },
          "lastUsageReportAt": {
            "description": "Last time metered usage was reported/flushed",
            "anyOf": [
              { "type": "string", "format": "date-time" },
              { "type": "null" }
            ]
          }
        }
      },
      "StealthAgentApiGenerateRequest": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiAcademicGenerateRequest"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiSeoGenerateRequest"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiSocialGenerateRequest"
          }
        ]
      },
      "StealthAgentApiAcademicGenerateRequest": {
        "type": "object",
        "required": ["preset", "prompt"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "academic"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or instructions for the academic-style document."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          }
        }
      },
      "StealthAgentApiSeoGenerateRequest": {
        "type": "object",
        "required": ["preset", "prompt"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "seo"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or brief for SEO-oriented content."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          }
        }
      },
      "StealthAgentApiSocialGenerateRequest": {
        "type": "object",
        "required": ["preset", "prompt", "platform"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "social"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or brief for the social post."
          },
          "platform": {
            "type": "string",
            "enum": ["linkedin", "medium"],
            "description": "Target platform for the social post."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          }
        }
      },
      "StealthAgentApiGenerateResponse": {
        "type": "object",
        "required": [
          "runId",
          "documentId",
          "preset",
          "result",
          "outputWords",
          "creditsSpent",
          "remainingCredits",
          "billingMode",
          "meteredChargedCredits"
        ],
        "properties": {
          "runId": {
            "type": "string",
            "description": "Identifier of the Stealth Agent run."
          },
          "documentId": {
            "type": "string",
            "description": "Identifier of the saved document for this run."
          },
          "preset": {
            "type": "string",
            "enum": ["academic", "seo", "social"]
          },
          "result": {
            "type": "string",
            "description": "Final content as markdown."
          },
          "outputWords": {
            "type": "integer",
            "minimum": 0,
            "description": "Word count of result used for billing."
          },
          "creditsSpent": {
            "type": "integer",
            "minimum": 0,
            "description": "Stealth API words charged for this request."
          },
          "remainingCredits": {
            "type": "integer",
            "minimum": 0,
            "description": "Prepaid word balance after this charge."
          },
          "billingMode": {
            "type": "string",
            "enum": ["prepaid", "payg"]
          },
          "meteredChargedCredits": {
            "type": "integer",
            "minimum": 0,
            "description": "Words billed to metered usage for this request (0 when fully prepaid)."
          }
        }
      },
      "StealthAgentApiCreateRunRequest": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiAcademicRunRequest"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiSeoRunRequest"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiSocialRunRequest"
          }
        ]
      },
      "StealthAgentApiAcademicRunRequest": {
        "type": "object",
        "required": ["preset", "prompt"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "academic"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or instructions for the academic-style document."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthAgentApiSeoRunRequest": {
        "type": "object",
        "required": ["preset", "prompt"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "seo"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or brief for SEO-oriented content."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthAgentApiSocialRunRequest": {
        "type": "object",
        "required": ["preset", "prompt", "platform"],
        "additionalProperties": false,
        "properties": {
          "preset": {
            "type": "string",
            "const": "social"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "description": "Topic or brief for the social post."
          },
          "platform": {
            "type": "string",
            "enum": ["linkedin", "medium"],
            "description": "Target platform for the social post."
          },
          "enableFactCheck": {
            "type": "boolean",
            "default": false,
            "description": "When true, runs a fact-check pass before humanization."
          },
          "enableImageGeneration": {
            "type": "boolean",
            "default": false,
            "description": "When true, may embed generated images in the final markdown."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthAgentApiCreateRunResponse": {
        "type": "object",
        "required": ["runId", "status", "statusUrl"],
        "properties": {
          "runId": {
            "type": "string",
            "description": "Identifier of the queued Stealth Agent run."
          },
          "status": {
            "type": "string",
            "const": "queued"
          },
          "statusUrl": {
            "type": "string",
            "description": "Relative polling URL for this run."
          }
        }
      },
      "StealthAgentApiRunStatusResponse": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiQueuedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiRunningRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiCompletedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiFailedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthAgentApiCancelledRunResponse"
          }
        ]
      },
      "StealthAgentApiQueuedRunResponse": {
        "type": "object",
        "required": ["runId", "status"],
        "properties": {
          "runId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "queued"
          }
        }
      },
      "StealthAgentApiRunBaseResponse": {
        "type": "object",
        "required": [
          "runId",
          "preset",
          "createdAt",
          "updatedAt",
          "currentStepId",
          "currentOperation"
        ],
        "properties": {
          "runId": {
            "type": "string"
          },
          "preset": {
            "type": "string",
            "enum": ["academic", "seo", "social"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "currentStepId": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "web_research",
                  "keywords_research",
                  "competitor_analysis",
                  "social_research",
                  "generate_text",
                  "meta_generation",
                  "fact_check",
                  "humanize",
                  "image_generation",
                  "citations"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "currentOperation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "StealthAgentApiRunningRunResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiRunBaseResponse"
          },
          {
            "type": "object",
            "required": ["status"],
            "properties": {
              "status": {
                "type": "string",
                "const": "running"
              }
            }
          }
        ]
      },
      "StealthAgentApiCompletedRunResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiRunBaseResponse"
          },
          {
            "type": "object",
            "required": [
              "status",
              "documentId",
              "result",
              "outputWords",
              "creditsSpent",
              "remainingCredits",
              "billingMode",
              "meteredChargedCredits"
            ],
            "properties": {
              "status": {
                "type": "string",
                "const": "completed"
              },
              "documentId": {
                "type": "string"
              },
              "result": {
                "type": "string",
                "description": "Final content as markdown."
              },
              "outputWords": {
                "type": "integer",
                "minimum": 0
              },
              "creditsSpent": {
                "type": "integer",
                "minimum": 0
              },
              "remainingCredits": {
                "type": "integer",
                "minimum": 0
              },
              "billingMode": {
                "type": "string",
                "enum": ["prepaid", "payg"]
              },
              "meteredChargedCredits": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        ]
      },
      "StealthAgentApiFailedRunResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiRunBaseResponse"
          },
          {
            "type": "object",
            "required": ["status", "error"],
            "properties": {
              "status": {
                "type": "string",
                "const": "failed"
              },
              "error": {
                "$ref": "#/components/schemas/StealthAgentApiRunError"
              }
            }
          }
        ]
      },
      "StealthAgentApiCancelledRunResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StealthAgentApiRunBaseResponse"
          },
          {
            "type": "object",
            "required": ["status", "error"],
            "properties": {
              "status": {
                "type": "string",
                "const": "cancelled"
              },
              "error": {
                "$ref": "#/components/schemas/StealthAgentApiRunError"
              }
            }
          }
        ]
      },
      "StealthAgentApiRunError": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "payg_terms_required",
              "payment_required",
              "billing_delayed",
              "generation_failed",
              "cancelled"
            ]
          },
          "message": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "StealthifyApiCreateRunRequest": {
        "type": "object",
        "required": ["model"],
        "oneOf": [{ "required": ["text"] }, { "required": ["prompt"] }],
        "additionalProperties": false,
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "description": "When rephrase is true, the existing text to humanize — send only that source text with no instruction wrappers such as 'Humanize the following text'. When rephrase is false, the topic or instructions for content generation. Maximum 3,000 words when rephrase is false."
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "description": "Same as text, under the name POST /api/stealthify uses. Send text or prompt, not both."
          },
          "rephrase": {
            "type": "boolean",
            "default": true,
            "description": "True humanizes text. False writes new content from text the same way as POST /api/stealthify with rephrase false, then humanizes that draft. Defaults to true."
          },
          "tone": {
            "type": "string",
            "enum": ["Standard", "HighSchool", "College", "PhD"],
            "default": "College",
            "description": "Style of generated content when rephrase is false. Ignored when rephrase is true and when writingMode is default."
          },
          "writingMode": {
            "type": "string",
            "enum": ["default", "essay"],
            "default": "default",
            "description": "How content is generated when rephrase is false. essay structures the output as an academic essay. default follows the prompt without forcing essay structure. Ignored when rephrase is true."
          },
          "qualityMode": {
            "type": "string",
            "enum": ["fast", "quality"],
            "default": "quality",
            "description": "On `standard`, `quality` runs quality checks and repairs and `fast` is a single-pass rewrite. On `super`, `quality` removes em dashes from the output and `fast` keeps them. `lite` ignores it."
          },
          "model": {
            "type": "string",
            "enum": ["super", "standard", "lite"],
            "description": "`super` is the flagship humanizer; `standard` is the previous-generation full rewrite; `lite` is faster AI-smell cleanup."
          },
          "outputFormat": {
            "type": "string",
            "enum": ["text", "markdown"],
            "default": "text",
            "description": "`text` returns plain text; `markdown` preserves/restores markdown."
          },
          "preservation": {
            "type": "boolean",
            "default": false,
            "description": "Keeps every marker such as [[T1]] byte-for-byte and in order while the text around it is humanized. Requires rephrase: true. See https://docs.stealthgpt.ai/api-reference/text-preservation"
          },
          "preservationOpen": {
            "type": "string",
            "default": "[[",
            "minLength": 1,
            "maxLength": 10,
            "description": "Opening delimiter of a marker, no spaces."
          },
          "preservationClose": {
            "type": "string",
            "default": "]]",
            "minLength": 1,
            "maxLength": 10,
            "description": "Closing delimiter of a marker, no spaces. Must differ from preservationOpen."
          },
          "preservationMaxLookahead": {
            "type": "integer",
            "default": 10,
            "minimum": 1,
            "maximum": 64,
            "description": "Most characters allowed between the delimiters. A [[ without a ]] within this many characters is ordinary text."
          },
          "preservationMode": {
            "type": "string",
            "enum": ["inline", "split"],
            "default": "inline",
            "description": "inline rewrites the text in one pass with the markers held in place and falls back to split for any text where a marker moved. split rewrites each stretch between two markers on its own."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthifyApiCreateRunFileRequest": {
        "type": "object",
        "required": ["file", "model"],
        "properties": {
          "file": {
            "type": "string",
            "format": "binary",
            "description": "Document to humanize, or the writer prompt when rephrase is false. Supported types: .pdf, .docx, .txt, .md. Maximum size: 4MB. Text is extracted server-side; scanned or image-only documents are not supported."
          },
          "rephrase": {
            "type": "boolean",
            "default": true,
            "description": "True humanizes the extracted text. False treats the extracted text as a writer prompt. Defaults to true."
          },
          "tone": {
            "type": "string",
            "enum": ["Standard", "HighSchool", "College", "PhD"],
            "default": "College",
            "description": "Style of generated content when rephrase is false. Ignored when rephrase is true."
          },
          "writingMode": {
            "type": "string",
            "enum": ["default", "essay"],
            "default": "default",
            "description": "How content is generated when rephrase is false. Ignored when rephrase is true."
          },
          "qualityMode": {
            "type": "string",
            "enum": ["fast", "quality"],
            "default": "quality",
            "description": "On `standard`, `quality` runs quality checks and repairs and `fast` is a single-pass rewrite. On `super`, `quality` removes em dashes from the output and `fast` keeps them. `lite` ignores it."
          },
          "model": {
            "type": "string",
            "enum": ["super", "standard", "lite"],
            "description": "`super` is the flagship humanizer; `standard` is the previous-generation full rewrite; `lite` is faster AI-smell cleanup."
          },
          "outputFormat": {
            "type": "string",
            "enum": ["text", "markdown"],
            "default": "text",
            "description": "`text` returns plain text; `markdown` preserves/restores markdown."
          },
          "preservation": {
            "type": "boolean",
            "default": false,
            "description": "Keeps every marker such as [[T1]] byte-for-byte and in order while the text around it is humanized. Requires rephrase: true. See https://docs.stealthgpt.ai/api-reference/text-preservation"
          },
          "preservationOpen": {
            "type": "string",
            "default": "[[",
            "minLength": 1,
            "maxLength": 10,
            "description": "Opening delimiter of a marker, no spaces."
          },
          "preservationClose": {
            "type": "string",
            "default": "]]",
            "minLength": 1,
            "maxLength": 10,
            "description": "Closing delimiter of a marker, no spaces. Must differ from preservationOpen."
          },
          "preservationMaxLookahead": {
            "type": "integer",
            "default": 10,
            "minimum": 1,
            "maximum": 64,
            "description": "Most characters allowed between the delimiters. A [[ without a ]] within this many characters is ordinary text."
          },
          "preservationMode": {
            "type": "string",
            "enum": ["inline", "split"],
            "default": "inline",
            "description": "inline rewrites the text in one pass with the markers held in place and falls back to split for any text where a marker moved. split rewrites each stretch between two markers on its own."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthifyApiCreateRunResponse": {
        "type": "object",
        "required": ["runId", "status", "statusUrl"],
        "properties": {
          "runId": {
            "type": "string",
            "description": "Identifier of the queued humanization run."
          },
          "status": {
            "type": "string",
            "const": "queued"
          },
          "statusUrl": {
            "type": "string",
            "description": "Relative polling URL for this run."
          }
        }
      },
      "StealthifyApiCreateBulkRunsRequest": {
        "type": "object",
        "required": ["items"],
        "additionalProperties": false,
        "properties": {
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "description": "Runs to queue. Each item is a POST /api/stealthify/runs JSON body plus an optional idempotencyKey.",
            "items": {
              "$ref": "#/components/schemas/StealthifyApiCreateBulkRunItem"
            }
          }
        }
      },
      "StealthifyApiCreateBulkRunItem": {
        "type": "object",
        "required": ["model"],
        "oneOf": [{ "required": ["text"] }, { "required": ["prompt"] }],
        "additionalProperties": false,
        "properties": {
          "idempotencyKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Optional key, unique within the request. Sending the same item with the same key again returns the run it already started, without queueing or billing it twice. To redo an item whose run failed, use a new key."
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "description": "When rephrase is true, the existing text to humanize — send only that source text with no instruction wrappers such as 'Humanize the following text'. When rephrase is false, the topic or instructions for content generation. Maximum 3,000 words when rephrase is false."
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "description": "Same as text, under the name POST /api/stealthify uses. Send text or prompt, not both."
          },
          "rephrase": {
            "type": "boolean",
            "default": true,
            "description": "True humanizes text. False writes new content from text the same way as POST /api/stealthify with rephrase false, then humanizes that draft. Defaults to true."
          },
          "tone": {
            "type": "string",
            "enum": ["Standard", "HighSchool", "College", "PhD"],
            "default": "College",
            "description": "Style of generated content when rephrase is false. Ignored when rephrase is true and when writingMode is default."
          },
          "writingMode": {
            "type": "string",
            "enum": ["default", "essay"],
            "default": "default",
            "description": "How content is generated when rephrase is false. essay structures the output as an academic essay. default follows the prompt without forcing essay structure. Ignored when rephrase is true."
          },
          "qualityMode": {
            "type": "string",
            "enum": ["fast", "quality"],
            "default": "quality",
            "description": "On `standard`, `quality` runs quality checks and repairs and `fast` is a single-pass rewrite. On `super`, `quality` removes em dashes from the output and `fast` keeps them. `lite` ignores it."
          },
          "model": {
            "type": "string",
            "enum": ["super", "standard", "lite"],
            "description": "`super` is the flagship humanizer; `standard` is the previous-generation full rewrite; `lite` is faster AI-smell cleanup."
          },
          "outputFormat": {
            "type": "string",
            "enum": ["text", "markdown"],
            "default": "text",
            "description": "`text` returns plain text; `markdown` preserves/restores markdown."
          },
          "preservation": {
            "type": "boolean",
            "default": false,
            "description": "Keeps every marker such as [[T1]] byte-for-byte and in order while the text around it is humanized. Requires rephrase: true. See https://docs.stealthgpt.ai/api-reference/text-preservation"
          },
          "preservationOpen": {
            "type": "string",
            "default": "[[",
            "minLength": 1,
            "maxLength": 10,
            "description": "Opening delimiter of a marker, no spaces."
          },
          "preservationClose": {
            "type": "string",
            "default": "]]",
            "minLength": 1,
            "maxLength": 10,
            "description": "Closing delimiter of a marker, no spaces. Must differ from preservationOpen."
          },
          "preservationMaxLookahead": {
            "type": "integer",
            "default": 10,
            "minimum": 1,
            "maximum": 64,
            "description": "Most characters allowed between the delimiters. A [[ without a ]] within this many characters is ordinary text."
          },
          "preservationMode": {
            "type": "string",
            "enum": ["inline", "split"],
            "default": "inline",
            "description": "inline rewrites the text in one pass with the markers held in place and falls back to split for any text where a marker moved. split rewrites each stretch between two markers on its own."
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional URL that receives a POST callback when the run reaches a terminal status."
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 255,
            "description": "Optional signing secret. When present, StealthGPT signs webhook callbacks with HMAC-SHA256."
          }
        }
      },
      "StealthifyApiCreateBulkRunsResponse": {
        "type": "object",
        "required": ["runs"],
        "properties": {
          "runs": {
            "type": "array",
            "description": "One queued run per item, in the same order as items.",
            "items": {
              "$ref": "#/components/schemas/StealthifyApiCreateRunResponse"
            }
          }
        }
      },
      "StealthifyApiRunStatusResponse": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/StealthifyApiQueuedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthifyApiRunningRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthifyApiCompletedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthifyApiFailedRunResponse"
          },
          {
            "$ref": "#/components/schemas/StealthifyApiCancelledRunResponse"
          }
        ]
      },
      "StealthifyApiQueuedRunResponse": {
        "type": "object",
        "required": ["runId", "status"],
        "properties": {
          "runId": { "type": "string" },
          "status": { "type": "string", "const": "queued" }
        }
      },
      "StealthifyApiRunBaseResponse": {
        "type": "object",
        "required": ["runId", "createdAt", "updatedAt", "currentOperation"],
        "properties": {
          "runId": { "type": "string" },
          "createdAt": { "type": "string", "format": "date-time" },
          "updatedAt": { "type": "string", "format": "date-time" },
          "currentOperation": {
            "anyOf": [{ "type": "string" }, { "type": "null" }]
          }
        }
      },
      "StealthifyApiRunningRunResponse": {
        "allOf": [
          { "$ref": "#/components/schemas/StealthifyApiRunBaseResponse" },
          {
            "type": "object",
            "required": ["status"],
            "properties": {
              "status": { "type": "string", "const": "running" }
            }
          }
        ]
      },
      "StealthifyApiCompletedRunResponse": {
        "allOf": [
          { "$ref": "#/components/schemas/StealthifyApiRunBaseResponse" },
          {
            "type": "object",
            "required": [
              "status",
              "result",
              "howLikelyToBeDetected",
              "wordsSpent",
              "creditsSpent",
              "remainingCredits",
              "billingMode",
              "meteredChargedCredits"
            ],
            "properties": {
              "status": { "type": "string", "const": "completed" },
              "result": {
                "type": "string",
                "description": "Humanized output text."
              },
              "howLikelyToBeDetected": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "description": "Human-likeness score (0-100). Higher is better: higher means more human / less likely to be flagged as AI; lower means more likely to be detected as AI-generated."
              },
              "wordsSpent": {
                "type": "integer",
                "minimum": 0,
                "description": "Words charged for this run. Super is billed at $0.05 / 100 words. standard and lite are billed at $0.20 / 1,000 words."
              },
              "creditsSpent": {
                "type": "integer",
                "minimum": 0,
                "description": "Same as wordsSpent. Kept on the async contract; it is not a separate charge."
              },
              "remainingCredits": { "type": "integer", "minimum": 0 },
              "billingMode": {
                "type": "string",
                "enum": ["prepaid", "payg"]
              },
              "meteredChargedCredits": { "type": "integer", "minimum": 0 },
              "preservation": {
                "$ref": "#/components/schemas/StealthifyPreservationReport"
              }
            }
          }
        ]
      },
      "StealthifyApiFailedRunResponse": {
        "allOf": [
          { "$ref": "#/components/schemas/StealthifyApiRunBaseResponse" },
          {
            "type": "object",
            "required": ["status", "error"],
            "properties": {
              "status": { "type": "string", "const": "failed" },
              "error": {
                "$ref": "#/components/schemas/StealthifyApiRunError"
              }
            }
          }
        ]
      },
      "StealthifyApiCancelledRunResponse": {
        "allOf": [
          { "$ref": "#/components/schemas/StealthifyApiRunBaseResponse" },
          {
            "type": "object",
            "required": ["status", "error"],
            "properties": {
              "status": { "type": "string", "const": "cancelled" },
              "error": {
                "$ref": "#/components/schemas/StealthifyApiRunError"
              }
            }
          }
        ]
      },
      "StealthifyApiRunError": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "payg_terms_required",
              "payment_required",
              "billing_delayed",
              "humanize_failed",
              "result_unavailable",
              "cancelled"
            ]
          },
          "message": { "type": "string", "minLength": 1 }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable error message"
          },
          "info": {
            "type": "array",
            "description": "Additional error details for validation errors",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "description": "Error code"
                },
                "expected": {
                  "type": "string",
                  "description": "Expected value type"
                },
                "received": {
                  "type": "string",
                  "description": "Received value type"
                },
                "path": {
                  "type": "array",
                  "description": "Path to the invalid parameter",
                  "items": {
                    "type": "string"
                  }
                },
                "message": {
                  "type": "string",
                  "description": "Detailed error message"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "api-token"
      }
    }
  }
}
