Configure your API key
You can provide your API key in two ways.Option 1: Environment variableexport PANGRAM_API_KEY=<your API key>
Option 2: Pass directly to the constructorfrom pangram import Pangram
pangram_client = Pangram(api_key="your-api-key")
Detect AI-generated text
Main prediction
Returns detailed analysis with AI-assistance detection and segment-level metrics.
The SDK submits an async inference task and waits for the completed result before returning.from pangram import Pangram
pangram_client = Pangram()
result = pangram_client.predict(text)
stage = result['stage'] # "STAGE_SUCCESS" after predict() completes.
# Analysis with AI-assistance detection.
fraction_ai = result['fraction_ai']
fraction_ai_assisted = result['fraction_ai_assisted']
fraction_human = result['fraction_human']
num_ai_segments = result['num_ai_segments']
# Access individual window classifications
for window in result['windows']:
label = window['label']
ai_assistance_score = window['ai_assistance_score']
confidence = window['confidence']
Dashboard link
from pangram import Pangram
pangram_client = Pangram()
result = pangram_client.predict(text, public_dashboard_link=True)
dashboard_link = result['dashboard_link']
Check for plagiarism
The plagiarism detection API checks text against a vast database of online content:from pangram import Pangram
pangram_client = Pangram()
text = "Text to check for plagiarism"
result = pangram_client.check_plagiarism(text)
if result['plagiarism_detected']:
print(f"Plagiarism detected! {result['percent_plagiarized']}% of the text may be plagiarized.")
for content in result['plagiarized_content']:
print(f"Found match at {content['source_url']}")
print(f"Matched text: {content['matched_text']}")
The response includes:
- Whether plagiarism was detected
- List of plagiarized content with source URLs
- Total number of sentences checked
- List of plagiarized sentences
- Percentage of text that was plagiarized
Deprecated Methods
The following SDK compatibility methods are deprecated and may be removed on August 1, 2026. Use predict() instead.
predict_short() — Forwards to predict() and returns the current async result schema
batch_predict() — Calls predict() once per input text