AI Detection
curl --request POST \
--url https://text.external-api.pangram.com/task \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "<string>"
}
'import requests
url = "https://text.external-api.pangram.com/task"
payload = { "text": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"task_id": "<string>",
"stage": "<string>",
"text": "<string>",
"version": "<string>",
"headline": "<string>",
"prediction": "<string>",
"prediction_short": "<string>",
"fraction_ai": 123,
"fraction_ai_assisted": 123,
"fraction_human": 123,
"num_ai_segments": 123,
"num_ai_assisted_segments": 123,
"num_human_segments": 123,
"dashboard_link": "<string>",
"windows": [
{
"text": "<string>",
"label": "<string>",
"ai_assistance_score": 123,
"confidence": "<string>",
"start_index": 123,
"end_index": 123,
"word_count": 123,
"token_length": 123,
"is_humanized": true,
"humanizer_score": 123
}
]
}REST API
AI Detection
Detect AI-generated and AI-assisted text using the async inference API
POST
/
task
AI Detection
curl --request POST \
--url https://text.external-api.pangram.com/task \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "<string>"
}
'import requests
url = "https://text.external-api.pangram.com/task"
payload = { "text": "<string>" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"task_id": "<string>",
"stage": "<string>",
"text": "<string>",
"version": "<string>",
"headline": "<string>",
"prediction": "<string>",
"prediction_short": "<string>",
"fraction_ai": 123,
"fraction_ai_assisted": 123,
"fraction_human": 123,
"num_ai_segments": 123,
"num_ai_assisted_segments": 123,
"num_human_segments": 123,
"dashboard_link": "<string>",
"windows": [
{
"text": "<string>",
"label": "<string>",
"ai_assistance_score": 123,
"confidence": "<string>",
"start_index": 123,
"end_index": 123,
"word_count": 123,
"token_length": 123,
"is_humanized": true,
"humanizer_score": 123
}
]
}For more information on billing units and pricing, check our pricing page for developers.
Current
Use the Bulk API when you need to analyze many texts as one asynchronous job.
Use
Example Response
In-Progress Response
Success Response
This example shows a Pangram 4 result. Pangram 4 returns
Failed Response
Current version
The current AI detection API creates an async task and returns a task ID. Poll the task endpoint until it reaches
STAGE_SUCCESS or STAGE_FAILED.GET /models to discover the selectors available to your API key. The REST API temporarily accepts an omitted model for backward compatibility and resolves it to "default". New integrations should always send a selector explicitly.
POST /task
Create an async AI detection task.POST https://text.external-api.pangram.com/task
Request
string
required
The input text to analyze.
string
default:"default"
A model selector returned by
GET /models.boolean
default:"false"
Whether to include a public dashboard link in the completed response.
Response
string
The ID of the async inference task.
Example
curl -X POST https://text.external-api.pangram.com/task \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"text": "AI-assisted passage. Human passage.",
"model": "pangram-4",
"public_dashboard_link": false
}'
from pangram import Pangram
pangram_client = Pangram()
result = pangram_client.predict(
"AI-assisted passage. Human passage.",
model="pangram-4",
)
{
"task_id": "123e4567-e89b-12d3-a456-426614174000"
}
Model selection errors
| Status Code | Description |
|---|---|
403 Forbidden | The requested model is not enabled for the API key. |
422 Unprocessable Entity | The model selector is malformed or unknown. |
503 Service Unavailable | The requested model is temporarily unavailable. |
GET /task/
Fetch the current status or completed result for an AI detection task.GET https://text.external-api.pangram.com/task/{task_id}
Request
string
required
The task ID returned by
POST /task.Response
string
The ID of the async inference task. Present while the task is in progress.
string
Current task stage. Terminal stages are
STAGE_SUCCESS and STAGE_FAILED.string
The analyzed text returned by the model. Pangram 4 may normalize the submitted text before inference; window offsets refer to this returned value. Present on success.
string
The API version identifier (e.g.,
"4.0" for Pangram 4). Present on success.string
Classification headline summarizing the result. Present on success.
string
Long-form prediction string describing the classification. Present on success.
string
Short-form prediction string. Pangram 4 returns
"AI", "Human", or "Mixed". Present on success.float
Fraction of text classified as AI-written (0.0–1.0). Present on success.
float
Fraction of text classified as AI-assisted (0.0–1.0). Present on success.
float
Fraction of text classified as human-written (0.0–1.0). Present on success.
integer
Number of text segments classified as AI. Present on success.
integer
Number of text segments classified as AI-assisted. Present on success.
integer
Number of text segments classified as human. Present on success.
string
A link to the dashboard page containing the full classification result. Present on success when
public_dashboard_link is true.array
List of text segments () analyzed individually. Present on success.
Show Window object properties
Show Window object properties
string
The window text.
string
Descriptive classification label. Pangram 4 returns
"AI-Generated", "AI-Assisted", or "Human Written".float
detailing the level of AI assistance (0.0–1.0).
string
for the classification (
"High", "Medium", "Low").integer
Starting character index in the returned top-level
text.integer
End-exclusive character index in the returned top-level
text.integer
Number of words in the window.
integer
Token length of the window.
boolean
Whether Pangram 4’s humanizer head classified the window as humanized. Present on every Pangram 4 window.
float
Pangram 4 humanizer-head score from 0.0–1.0. Present on every Pangram 4 window.
Example
cURL
curl -X GET https://text.external-api.pangram.com/task/123e4567-e89b-12d3-a456-426614174000 \
-H "x-api-key: your_api_key_here"
{
"task_id": "123e4567-e89b-12d3-a456-426614174000",
"stage": "STAGE_PREPROCESSING"
}
version: "4.0", uses "AI-Assisted" instead of lightly or moderately assisted window labels, and keeps confidence as "Low", "Medium", or "High".
{
"stage": "STAGE_SUCCESS",
"text": "AI-assisted passage. Human passage.",
"version": "4.0",
"headline": "AI Assisted",
"prediction": "We believe that this text is a mix of AI-assisted and human-written content.",
"prediction_short": "Mixed",
"fraction_ai": 0.0,
"fraction_ai_assisted": 0.6,
"fraction_human": 0.4,
"num_ai_segments": 0,
"num_ai_assisted_segments": 1,
"num_human_segments": 1,
"windows": [
{
"text": "AI-assisted passage. ",
"label": "AI-Assisted",
"ai_assistance_score": 0.55,
"confidence": "High",
"start_index": 0,
"end_index": 21,
"word_count": 2,
"token_length": 5,
"is_humanized": true,
"humanizer_score": 0.91
},
{
"text": "Human passage.",
"label": "Human Written",
"ai_assistance_score": 0.02,
"confidence": "Medium",
"start_index": 21,
"end_index": 35,
"word_count": 2,
"token_length": 4,
"is_humanized": false,
"humanizer_score": 0.0
}
]
}
{
"stage": "STAGE_FAILED",
"text": "",
"version": "",
"headline": "preprocessing: Input text contains no valid text after preprocessing",
"prediction": "",
"prediction_short": "",
"fraction_ai": 0.0,
"fraction_ai_assisted": 0.0,
"fraction_human": 0.0,
"num_ai_segments": 0,
"num_ai_assisted_segments": 0,
"num_human_segments": 0,
"windows": []
}