---
title: "Detect AI-generated text"
method: POST
path: "/api/v1/detect/ai"
tags: ["Detect"]
---

# Detect AI-generated text

`POST /api/v1/detect/ai`

## Request

- Base URL: `https://glim.sh`
- URL: `https://glim.sh/api/v1/detect/ai`
- Auth: one of:
  - none
  - API key in header `x-api-key`
  - HTTP bearer
  - API key in query parameter `apiKey`

Score any text for AI authorship. Returns an overall verdict (AI / human / mixed) with confidence, the AI / human / AI-assisted fractions, and a segment-by-segment breakdown showing which parts read as AI-written - each segment carries its full text, its char offsets into the text you submitted, and a humanizer flag (AI output run through paraphrasing/'humanizer' tools). Price scales with length: $0.06 per 100 words, rounded up, minimum $0.06 - the exact amount is in the 402 challenge for the body you post. Max input 20,000 characters. The legacy `tier` field is accepted and ignored: every call runs the highest-accuracy detection class.

## Request body

- object: Input for POST /api/v1/detect/ai
  - `text` string, required: Text to analyze, plain text, 50+ characters, max 20,000. Detection reliability improves with length; very short texts return lower-confidence verdicts.

## Response `200`

Detection verdict with per-segment breakdown

- object
  - `headline` string, required: Short verdict, e.g. 'AI Generated', 'AI Detected', 'Human Written'
  - `prediction` string, required: One-sentence verdict in plain English
  - `prediction_short` string, required: Verdict class: AI, Mixed, or Human
  - `fraction_ai` number, required: Fraction of the text judged AI-generated, 0-1
  - `fraction_ai_assisted` number, required: Fraction judged AI-assisted, 0-1
  - `fraction_human` number, required: Fraction judged human-written, 0-1
  - `num_ai_segments` integer, required: Segments labeled AI-Generated
  - `num_ai_assisted_segments` integer, required: Segments labeled AI-Assisted
  - `num_human_segments` integer, required: Segments labeled Human
  - `confidence` string, required: Confidence carrying the overall verdict: High, Medium, or Low
  - `version` string, required: Detector model version that produced this verdict (e.g. '4.0')
  - `word_count` integer, required: Words analyzed
  - `tier_used` 'premium', required: Deprecated: always 'premium' - every call runs the single remaining (highest-accuracy) detection class. Retained for backward compatibility.
  - `cost_usd` number, required: Amount charged for this call, in USD
  - `segments` object[], required: Per-segment breakdown, in reading order
    - `label` string, required: Detector verdict for this segment (e.g. 'AI-Generated', 'Human')
    - `score` number, required: AI-assistance score for this segment, 0-1
    - `ai_assistance_score` number, required: Same value as score, under the upstream detector's field name
    - `confidence` string, required: Detector confidence for this segment: High, Medium, or Low
    - `text` string, required: Full text of this segment, sliced from the text you submitted
    - `word_start` integer, required: 1-based word position where this segment starts
    - `word_end` integer, required: 1-based word position where this segment ends
    - `word_count` integer, required
    - `token_length` integer, required: Tokens in this segment, as counted by the detector
    - `start_index` integer, required: Character offset of this segment's first word in the text you submitted
    - `end_index` integer, required: Character offset just past this segment's last word in the text you submitted (exclusive)
    - `preview` string, required: Opening excerpt of the segment
    - `is_humanized` boolean: True when this segment reads as AI output passed through a paraphrasing/'humanizer' tool. Absent means not evaluated, not false.
    - `humanizer_score` number: Humanizer likelihood, 0-1.

## Other responses

- `400`: Bad Request
- `402`: Payment Required
- `502`: Upstream Error
- `503`: Temporarily Unavailable

---

[API](https://skmtc.dev/glim/apis/glim-sh.md) · [All operations](https://skmtc.dev/glim/apis/glim-sh/llms.txt) · [OpenAPI document](https://skmtc.dev/glim/apis/glim-sh/revisions/0094e5226d73?raw)
