Skip to main content
1

Install the SDK

pip install pangram-sdk
2

Configure your API key

You can provide your API key in two ways.Option 1: Environment variable
export PANGRAM_API_KEY=<your API key>
Option 2: Pass directly to the constructor
from pangram import Pangram

pangram_client = Pangram(api_key="your-api-key")
3

Detect AI-generated text

Main prediction

Returns detailed analysis with AI-assistance detection and segment-level metrics.
from pangram import Pangram

pangram_client = Pangram()
result = pangram_client.predict(text)

# V3 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']

Short prediction

Single Pangram model prediction, cuts off text at 512 tokens.
from pangram import Pangram

pangram_client = Pangram()
result = pangram_client.predict_short(text)

# Score in range [0, 1] where 0 is human-written and 1 is AI-generated
score = result['ai_likelihood']
4

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 methods are deprecated and will be removed by April 1st, 2026. Use predict() instead.
  • predict_extended() — Use predict() instead
  • batch_predict() — Use predict() instead
  • predict_sliding_window() — Use predict() instead