> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stealthgpt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Stealth Agent

> Long-form Stealth Agent generation via POST /api/stealthify/agent

The `/api/stealthify/agent` endpoint runs a **Stealth Agent** pipeline: research, generation, humanization, and optional fact-checking and image insertion. It uses the same Stealth API word balance and pay-as-you-go rules as `/api/stealthify`.

Requests can take several minutes. Use a client timeout of **at least 10 minutes** (the server allows up to 600 seconds).

<Info>
  For production integrations, workflow engines, or UI backends, use the async [`POST /api/stealthify/agent/runs`](/api-reference/endpoints/stealthify-agent-runs) endpoint. It returns immediately with a `runId`, supports `idempotency-key`, and can send a webhook callback.
</Info>

## Authentication

<ParamField header="api-token" type="string" required>
  Your Stealth API token from the [Stealth API dashboard](https://www.stealthgpt.ai/stealthapi).
</ParamField>

## Request body

Send JSON with a required `preset` that selects one of three shapes (discriminated union). Unknown fields are rejected (`strict` schema).

### Academic

<ParamField body="preset" type="string" required>
  Must be `"academic"`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Topic or instructions for the academic-style document (non-empty).
</ParamField>

<ParamField body="enableFactCheck" type="boolean" default="false">
  When `true`, runs a fact-check pass on the draft and applies fixes before humanization.
</ParamField>

<ParamField body="enableImageGeneration" type="boolean" default="false">
  When `true`, may embed generated images in the final markdown where supported.
</ParamField>

### SEO

<ParamField body="preset" type="string" required>
  Must be `"seo"`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Topic or brief for SEO-oriented content (non-empty).
</ParamField>

<ParamField body="enableFactCheck" type="boolean" default="false">
  Same behavior as academic.
</ParamField>

<ParamField body="enableImageGeneration" type="boolean" default="false">
  Same behavior as academic.
</ParamField>

### Social

<ParamField body="preset" type="string" required>
  Must be `"social"`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Topic or brief for the social post (non-empty).
</ParamField>

<ParamField body="platform" type="string" required>
  Target platform: `"linkedin"` or `"medium"`.
</ParamField>

<ParamField body="enableFactCheck" type="boolean" default="false">
  Same behavior as academic.
</ParamField>

<ParamField body="enableImageGeneration" type="boolean" default="false">
  Same behavior as academic.
</ParamField>

## Successful response (200)

<ResponseField name="runId" type="string">
  Identifier of the Stealth Agent run (stored server-side).
</ResponseField>

<ResponseField name="documentId" type="string">
  Identifier of the saved document record for this run.
</ResponseField>

<ResponseField name="preset" type="string">
  Echoes the request preset: `academic`, `seo`, or `social`.
</ResponseField>

<ResponseField name="result" type="string">
  Final content as markdown (same primary output that is stored for the document; may include embedded images when `enableImageGeneration` is true).
</ResponseField>

<ResponseField name="outputWords" type="number">
  Word count of `result` used for billing.
</ResponseField>

<ResponseField name="creditsSpent" type="number">
  Stealth API words charged for this request (see [Pricing](/api-reference/pricing)).
</ResponseField>

<ResponseField name="remainingCredits" type="number">
  Prepaid word balance after this charge (metered usage may still be reported separately).
</ResponseField>

<ResponseField name="billingMode" type="string">
  `"prepaid"` when the request was covered from balance, or `"payg"` when metered pay-as-you-go usage was applied for part or all of the charge.
</ResponseField>

<ResponseField name="meteredChargedCredits" type="number">
  Words billed to metered usage for this request (0 when fully prepaid).
</ResponseField>

## Errors

| Status  | Meaning                                                                                                                        |
| ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **400** | Invalid JSON or validation error. Body may include `message` and `info` (issue details).                                       |
| **401** | Missing `api-token` header or token not found.                                                                                 |
| **402** | Insufficient credits, pay-as-you-go not available, payment method missing, or billing cap delay. `message` describes the case. |
| **499** | Request was aborted (client disconnect or cancellation).                                                                       |
| **500** | Server error. `message` may contain a short description.                                                                       |

## Example: academic

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
    --url 'https://stealthgpt.ai/api/stealthify/agent' \
    --header 'Content-Type: application/json' \
    --header 'api-token: YOUR_API_TOKEN' \
    --max-time 600 \
    --data '{
      "preset": "academic",
      "prompt": "Outline creatine benefits for older adults in resistance training",
      "enableFactCheck": true,
      "enableImageGeneration": false
    }'
  ```

  ```python python theme={null}
  import requests

  response = requests.post(
      "https://stealthgpt.ai/api/stealthify/agent",
      headers={
          "api-token": "YOUR_API_TOKEN",
          "Content-Type": "application/json",
      },
      json={
          "preset": "academic",
          "prompt": "Outline creatine benefits for older adults in resistance training",
          "enableFactCheck": True,
          "enableImageGeneration": False,
      },
      timeout=600,
  )
  print(response.status_code, response.json())
  ```

  ```javascript nodejs theme={null}
  const axios = require("axios");

  axios
    .post(
      "https://stealthgpt.ai/api/stealthify/agent",
      {
        preset: "academic",
        prompt:
          "Outline creatine benefits for older adults in resistance training",
        enableFactCheck: true,
        enableImageGeneration: false,
      },
      {
        headers: {
          "api-token": "YOUR_API_TOKEN",
          "Content-Type": "application/json",
        },
        timeout: 600_000,
      },
    )
    .then((r) => console.log(r.data))
    .catch(console.error);
  ```
</CodeGroup>

## Example: social

```json theme={null}
{
  "preset": "social",
  "prompt": "Post about sustainable remote work habits",
  "platform": "linkedin",
  "enableFactCheck": false,
  "enableImageGeneration": true
}
```

## Usage notes

* Billing uses **output words** only: charged words = `ceil(outputWords × 10)` toward your Stealth API balance (see [Pricing](/api-reference/pricing)).
* You must have prepaid words **or** accepted pay-as-you-go terms with a valid payment method when balance is low—same rules as other Stealth API endpoints.
* Prefer the async runs endpoint when retries are possible: `POST /api/stealthify/agent/runs` supports `idempotency-key`.
* Retry synchronous requests with care: each successful `200` run creates a new run and document and charges credits again.
