Installation
PangramText
The main client class for interacting with the Pangram Labs API.Constructor
Your API key for Pangram Labs. If not provided, the
PANGRAM_API_KEY environment variable will be used.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.The text to be classified.
Whether to include a public dashboard link in the response.
The input text.
The API version identifier (e.g.,
"3.0").Classification headline summarizing the result.
Long-form prediction string describing the classification.
Short-form prediction string (
"AI", "AI-Assisted", "Human", "Mixed").Fraction of text classified as AI-written (0.0–1.0).
Fraction of text classified as AI-assisted (0.0–1.0).
Fraction of text classified as human-written (0.0–1.0).
Number of text segments classified as AI.
Number of text segments classified as AI-assisted.
Number of text segments classified as human.
Dashboard link. Only present when
public_dashboard_link is True.List of text windows and their classifications. Each window contains:
ValueError if the API returns an error.
predict_short()
Classify text using the short endpoint. Cuts off text at 512 tokens.The text to be classified.
The input text.
Classification score from 0.0 (human) to 1.0 (AI).
A string representing the classification.
check_plagiarism()
Check text for potential plagiarism against a database of online content.The text to check for plagiarism.
The input text.
Whether plagiarism was detected.
List of detected plagiarized content with source URLs.
Total number of sentences checked.
List of sentences detected as plagiarized.
Percentage of text detected as plagiarized.
ValueError if the API returns an error.
Deprecated Methods
predict_extended() Deprecated
Extended analysis with adaptive boundaries. Usepredict() instead.
batch_predict() Deprecated
Classify a batch of texts. Iterates through the batch and callspredict() for each text.
predict_sliding_window() Deprecated
Classify a long document using a sliding window. Usepredict() instead.