Skip to main content

No project description provided

Project description

Pangram Labs Python Package

Installation

pip install pangram-sdk

Add your API key

Add your API key as an environment variable, or pass it directly to the Pangram constructor.

export PANGRAM_API_KEY=<your API key>
from pangram import Pangram
# If the environment variable PANGRAM_API_KEY is set:
pangram_client = Pangram()

# Otherwise, pass the API key directly:
my_api_key = ''  # Fill this in with your API key.
pangram_client = Pangram(api_key=my_api_key)

Make a request

Main prediction method (V3 - AI-assisted detection and segment-level analysis):

from pangram import Pangram
pangram_client = Pangram()

result = pangram_client.predict(text)
# V3 analysis with AI-assisted 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']  # e.g., "AI-Generated", "Moderately AI-Assisted"
    ai_assistance_score = window['ai_assistance_score']
    confidence = window['confidence']  # "High", "Medium", "Low"

Short prediction (scans first ~400 words of text, returns a single prediction):

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

Extended prediction (returns windows of AI/human text in a longer document):

from pangram import Pangram
pangram_client = Pangram()

result = pangram_client.predict_extended(text)
# Extended analysis with windowed results and detailed metrics
avg_score = result['avg_ai_likelihood']
max_score = result['max_ai_likelihood']
percent_ai = result['percent_ai']

Make a batch request

from pangram import Pangram
pangram_client = Pangram()

text_batch = ["abc", "def"]

results = pangram_client.batch_predict(text_batch)
for result in results:
    text = result['text']
    score = result['ai_likelihood']

Deprecated Methods

The following methods are deprecated and will be removed by April 1st, 2026:

  • predict_sliding_window() - Use predict_extended() instead for better performance
  • predict_with_dashboard_link() - Use predict_extended with the dashboard flag instead

Questions? Email support@pangram.com!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pangram_sdk-0.1.9.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pangram_sdk-0.1.9-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pangram_sdk-0.1.9.tar.gz.

File metadata

  • Download URL: pangram_sdk-0.1.9.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pangram_sdk-0.1.9.tar.gz
Algorithm Hash digest
SHA256 9c0200bfa0a1a8ecbdf0c1aaa020f80a028520cf3dd11cad2cb294d5e79f6730
MD5 4ead62ce526b2ee076e3b90a6ba2f17f
BLAKE2b-256 22e6ac30cb2732153e3fef97e98e49d0ee5612c811779e4617d7a98a345242d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pangram_sdk-0.1.9.tar.gz:

Publisher: publish-to-pypi.yml on pangramlabs/pangram-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pangram_sdk-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: pangram_sdk-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pangram_sdk-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f840b023ccde34e1d95a0f78252fa93b57ead48ab01d0125128cec6afd0b5ef0
MD5 d62d0bd718250cfb94af2fad8d22682b
BLAKE2b-256 833b354343ed3fe752f728349fd8131f0a7f1260531103ade2edd2e4e56b3af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pangram_sdk-0.1.9-py3-none-any.whl:

Publisher: publish-to-pypi.yml on pangramlabs/pangram-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page