Skip to main content

Installation

pip install pangram-sdk

PangramText

The main client class for interacting with the Pangram Labs API.

Constructor

from pangram import Pangram

client = Pangram(api_key="your-api-key")
api_key
string
Your API key for Pangram Labs. If not provided, the PANGRAM_API_KEY environment variable will be used.
Raises ValueError if the API key is not provided and not set in the environment.

predict()

Classify text as AI-generated, AI-assisted, or human-written using the V3 API. Returns analysis with windowed, segment-level results.
result = client.predict(text, public_dashboard_link=False)
Parameters
text
string
required
The text to be classified.
Whether to include a public dashboard link in the response.
Returns A dictionary with the following fields:
text
string
The input text.
version
string
The API version identifier (e.g., "3.0").
headline
string
Classification headline summarizing the result.
prediction
string
Long-form prediction string describing the classification.
prediction_short
string
Short-form prediction string ("AI", "AI-Assisted", "Human", "Mixed").
fraction_ai
float
Fraction of text classified as AI-written (0.0–1.0).
fraction_ai_assisted
float
Fraction of text classified as AI-assisted (0.0–1.0).
fraction_human
float
Fraction of text classified as human-written (0.0–1.0).
num_ai_segments
integer
Number of text segments classified as AI.
num_ai_assisted_segments
integer
Number of text segments classified as AI-assisted.
num_human_segments
integer
Number of text segments classified as human.
Dashboard link. Only present when public_dashboard_link is True.
windows
list
List of text windows and their classifications. Each window contains:
Raises ValueError if the API returns an error.

predict_short()

Classify text using the short endpoint. Cuts off text at 512 tokens.
result = client.predict_short(text)
Parameters
text
string
required
The text to be classified.
Returns A dictionary with the following fields:
text
string
The input text.
ai_likelihood
float
Classification score from 0.0 (human) to 1.0 (AI).
prediction
string
A string representing the classification.

check_plagiarism()

Check text for potential plagiarism against a database of online content.
result = client.check_plagiarism(text)
Parameters
text
string
required
The text to check for plagiarism.
Returns A dictionary with the following fields:
text
string
The input text.
plagiarism_detected
boolean
Whether plagiarism was detected.
plagiarized_content
list
List of detected plagiarized content with source URLs.
total_sentences
integer
Total number of sentences checked.
plagiarized_sentences
list
List of sentences detected as plagiarized.
percent_plagiarized
float
Percentage of text detected as plagiarized.
Raises ValueError if the API returns an error.

Deprecated Methods

The following methods are deprecated and will be removed by April 1st, 2026. Use predict() instead.

predict_extended() Deprecated

Extended analysis with adaptive boundaries. Use predict() instead.
result = client.predict_extended(text)

batch_predict() Deprecated

Classify a batch of texts. Iterates through the batch and calls predict() for each text.
results = client.batch_predict(["text one", "text two"])

predict_sliding_window() Deprecated

Classify a long document using a sliding window. Use predict() instead.
result = client.predict_sliding_window(text)