### Install the Pangram Python SDK Source: https://docs.pangram.com/quickstart Install the SDK using pip. This is the first step to using the Pangram Python library. ```bash pip install pangram-sdk ``` -------------------------------- ### AI Detection Endpoint Example Source: https://docs.pangram.com/api-reference/introduction This example demonstrates how to make a POST request to the AI detection endpoint using cURL, Python, and JavaScript. Remember to replace '' with your actual API key. ```APIDOC ## POST /v3 ### Description Detects AI-generated content in the provided text. ### Method POST ### Endpoint https://text.api.pangram.com/v3 ### Parameters #### Request Body - **text** (string) - Required - The text to analyze for AI generation. ### Request Example ```json { "text": "Your text here" } ``` ### Authentication All API requests must include your API key in the `x-api-key` header. ### Response #### Success Response (200) (Response schema not provided in source) #### Error Codes - `400 Bad Request`: The request body is not properly formatted. - `401 Unauthorized`: The `x-api-key` is missing, invalid, or does not have enough credits to process the request. - `500 Internal Server Error`: There was an error processing the request. ``` -------------------------------- ### Plagiarism Check Response Example Source: https://docs.pangram.com/quickstart-rest This is an example JSON response for the plagiarism check endpoint, indicating if plagiarism was detected and providing details on plagiarized content. ```json { "text": "Text to check for plagiarism", "plagiarism_detected": true, "plagiarized_content": [ { "source_url": "https://example.com/source", "matched_text": "Text to check for plagiarism", "similarity_score": 0.95 } ], "total_sentences": 1, "plagiarized_sentences": 1, "percent_plagiarized": 100.0 } ``` -------------------------------- ### AI Detection Response Example Source: https://docs.pangram.com/quickstart-rest This is an example JSON response for the AI detection endpoint, detailing text authorship breakdown and segment-level classifications. ```json { "text": "The text to analyze", "version": "3.0", "headline": "AI Detected", "prediction": "We are confident that this document is a mix of AI-generated, AI-assisted, and human-written content", "prediction_short": "Mixed", "fraction_ai": 0.70, "fraction_ai_assisted": 0.20, "fraction_human": 0.10, "num_ai_segments": 7, "num_ai_assisted_segments": 2, "num_human_segments": 1, "windows": [ { "text": "The text to analyze", "label": "AI-Generated", "ai_assistance_score": 0.85, "confidence": "High", "start_index": 0, "end_index": 19, "word_count": 4, "token_length": 5 } ] } ``` -------------------------------- ### Example Response for Text Classification Source: https://docs.pangram.com/api-reference/deprecated-endpoints This is an example of the JSON response received after classifying text. It includes prediction details, likelihood scores, and a dashboard link. ```json { "text": "Extremely long text.", "prediction": "Highly likely AI", "ai_likelihood": 1.0, "dashboard_link": "https://www.pangram.com/history/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "max_ai_likelihood": 1.0, "avg_ai_likelihood": 0.6, "fraction_ai_content": 0.5, "windows": [ { "text": "Extremely long", "ai_likelihood": 1.0, "prediction": "Highly likely AI" }, { "text": "long text.", "ai_likelihood": 0.2, "prediction": "Unlikely AI" } ] } ``` -------------------------------- ### Set API Key with cURL Source: https://docs.pangram.com/quickstart-rest Set your API key in the `x-api-key` header for all requests. This example shows how to export it as an environment variable. ```bash export PANGRAM_API_KEY= ``` -------------------------------- ### Example AI Detection API Response Source: https://docs.pangram.com/api-reference/ai-detection This is an example of the JSON response you can expect from the AI Detection API (v3). It includes overall confidence, segment details, and fractions of AI, AI-assisted, and human content. ```json { "text": "The text to analyze with V3 classification", "version": "3.0", "headline": "AI Detected", "prediction": "We are confident that this document is a mix of AI-generated, AI-assisted, and human-written content", "prediction_short": "Mixed", "fraction_ai": 0.70, "fraction_ai_assisted": 0.20, "fraction_human": 0.10, "num_ai_segments": 7, "num_ai_assisted_segments": 2, "num_human_segments": 1, "windows": [ { "text": "The text to analyze", "label": "AI-Generated", "ai_assistance_score": 0.85, "confidence": "High", "start_index": 0, "end_index": 19, "word_count": 4, "token_length": 5 }, { "text": "with V3 classification", "label": "Moderately AI-Assisted", "ai_assistance_score": 0.45, "confidence": "Medium", "start_index": 20, "end_index": 49, "word_count": 4, "token_length": 5 } ] } ``` -------------------------------- ### Detect AI-generated text (V3) with cURL Source: https://docs.pangram.com/quickstart-rest Use this endpoint to get a detailed analysis of text, including AI-assistance detection and segment-level metrics. Requires the API key in the header. ```bash curl -X POST https://text.api.pangram.com/v3 \ -H "Content-Type: application/json" \ -H "x-api-key: $PANGRAM_API_KEY" \ -d '{ "text": "The text to analyze" }' ``` -------------------------------- ### Initialize Pangram Client Source: https://docs.pangram.com/sdk/python Initialize the main client class for interacting with the Pangram Labs API. Provide your API key directly or ensure the PANGRAM_API_KEY environment variable is set. ```python from pangram import Pangram client = Pangram(api_key="your-api-key") ``` -------------------------------- ### PangramText Constructor Source: https://docs.pangram.com/sdk/python Initializes the PangramText client. It requires an API key, which can be provided directly or via the PANGRAM_API_KEY environment variable. Raises ValueError if the API key is missing. ```APIDOC ## Constructor ```python from pangram import Pangram client = Pangram(api_key="your-api-key") ``` ### Parameters * **api_key** (string) - Required - 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. ``` -------------------------------- ### Configure Pangram API Key Source: https://docs.pangram.com/quickstart Set your API key either as an environment variable or directly when initializing the Pangram client. ```bash export PANGRAM_API_KEY= ``` ```python from pangram import Pangram pangram_client = Pangram(api_key="your-api-key") ``` -------------------------------- ### POST / Source: https://docs.pangram.com/api-reference/deprecated-endpoints Extended analysis with adaptive boundaries and windowed results. ```APIDOC ## POST / ### Description Extended analysis with adaptive boundaries and windowed results. ### Method POST ### Endpoint https://text-extended.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The input text to classify with extended analysis. - **dashboard** (boolean) - Optional - Enable dashboard integration. Defaults to false. - **is_public** (boolean) - Optional - Control visibility in dashboard. Defaults to true. ### Response #### Success Response (200) - **text** (string) - The input text that was analyzed. - **avg_ai_likelihood** (float) - Weighted average AI likelihood score across all windows. - **max_ai_likelihood** (float) - Maximum AI likelihood score among all windows. - **prediction** (string) - Long-form prediction string representing the classification. - **prediction_short** (string) - Short-form prediction string (`"AI"`, `"Human"`, `"Mixed"`). - **headline** (string) - Classification headline summarizing the result. - **windows** (array) - List of text segments analyzed individually. Each window contains `text`, `ai_likelihood`, `label`, `confidence`, `start_index`, `end_index`, and `word_count`. - **window_likelihoods** (array) - AI likelihood scores for each window (list of values from 0.0 to 1.0). - **window_indices** (array) - Indices indicating the position of each window in the original text (list of `[start_char_index, end_char_index]`). - **fraction_human** (float) - Fraction of text classified as human-written (0.0–1.0). - **fraction_ai** (float) - Fraction of text classified as AI-written (0.0–1.0). - **fraction_mixed** (float) - Fraction of text classified as mixed content (0.0–1.0). - **metadata** (object) - Additional metadata about the analysis. - **version** (string) - Analysis version identifier (`"adaptive_boundaries"`). - **dashboard_link** (string) - Dashboard link. Only present when `dashboard` is `true`. `is_public` controls visibility. ### Request Example ```json { "text": "The text to analyze with extended classification", "dashboard": true, "is_public": false } ``` ### Response Example ```json { "text": "The text to analyze with extended classification", "avg_ai_likelihood": 0.75, "max_ai_likelihood": 0.92, "prediction": "Primarily AI-generated, or heavily AI-assisted", "prediction_short": "AI", "headline": "AI Detected", "windows": [ { "text": "The text to analyze", "ai_likelihood": 0.85, "label": "AI", "confidence": "Medium", "start_index": 0, "end_index": 19, "word_count": 4 }, { "text": "with extended classification", "ai_likelihood": 0.65, "label": "AI", "confidence": "Low", "start_index": 20, "end_index": 47, "word_count": 3 } ], "window_likelihoods": [0.85, 0.65], "window_indices": [[0, 19], [20, 47]], "fraction_human": 0.25, "fraction_ai": 0.70, "fraction_mixed": 0.05, "metadata": { "request_id": "123e4567-e89b-12d3-a456-426614174000" }, "version": "adaptive_boundaries", "dashboard_link": "https://www.pangram.com/history/123e4567-e89b-12d3-a456-426614174000" } ``` ``` -------------------------------- ### POST / Source: https://docs.pangram.com/api-reference/plagiarism-detection Check text for potential plagiarism by comparing it against a vast database of online content. ```APIDOC ## POST / ### Description Check text for potential plagiarism by comparing it against a vast database of online content. ### Method POST ### Endpoint https://plagiarism.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The input text to check for plagiarism. ### Response #### Success Response (200) - **text** (string) - The input text that was checked. - **plagiarism_detected** (boolean) - Whether plagiarism was detected in the text. - **plagiarized_content** (array) - A list of detected plagiarized content, including source URLs and matched text. - **source_url** (string) - The URL of the source where the match was found. - **matched_text** (string) - The text that matched the source. - **similarity_score** (float) - A value from 0 to 1 indicating how closely the text matches the source. Higher values mean a closer match. - **total_sentences** (integer) - Total number of sentences in the input text. - **plagiarized_sentences** (integer) - Number of sentences that were detected as plagiarized. - **percent_plagiarized** (float) - The proportion of input sentences that matched existing online content, expressed as a percentage (0–100). ### Request Example ```json { "text": "The text to check for plagiarism" } ``` ### Response Example ```json { "text": "The text to check for plagiarism", "plagiarism_detected": true, "plagiarized_content": [ { "source_url": "https://example.com/source", "matched_text": "The text to check for plagiarism", "similarity_score": 0.95 } ], "total_sentences": 1, "plagiarized_sentences": 1, "percent_plagiarized": 100.0 } ``` ``` -------------------------------- ### Analyze Text with AI Detection API (v3) Source: https://docs.pangram.com/api-reference/ai-detection Use this endpoint to send text for AI detection analysis. Ensure you include your API key and set the correct Content-Type header. ```bash curl -X POST https://text.api.pangram.com/v3 \ -H "Content-Type: application/json" \ -H "x-api-key: your_api_key_here" \ -d '{ "text": "The text to analyze with V3 classification" }' ``` ```python from pangram import Pangram pangram_client = Pangram() result = pangram_client.predict("The text to analyze with V3 classification") ``` -------------------------------- ### Authenticate API Request with Python Source: https://docs.pangram.com/api-reference/introduction This Python script demonstrates how to authenticate API requests using the requests library. Include your API key in the x-api-key header and set the Content-Type to application/json. ```python import requests response = requests.post( "https://text.api.pangram.com/v3", headers={ "Content-Type": "application/json", "x-api-key": "" }, json={"text": "Your text here"} ) ``` -------------------------------- ### Check Plagiarism with cURL Source: https://docs.pangram.com/api-reference/plagiarism-detection Use this cURL command to send a POST request to the Plagiarism Detection API. Ensure you replace 'your_api_key_here' with your actual API key and provide the text to be checked in the JSON payload. ```bash curl -X POST https://plagiarism.api.pangram.com \ -H "Content-Type: application/json" \ -H "x-api-key: your_api_key_here" \ -d '{ "text": "The text to check for plagiarism" }' ``` -------------------------------- ### Authenticate API Request with cURL Source: https://docs.pangram.com/api-reference/introduction Use this cURL command to authenticate your API requests by including your API key in the x-api-key header. Ensure the Content-Type is set to application/json. ```bash curl -X POST https://text.api.pangram.com/v3 \ -H "Content-Type: application/json" \ -H "x-api-key: " \ -d '{"text": "Your text here"}' ``` -------------------------------- ### Analyze Text with AI Detection API (v3) Source: https://docs.pangram.com/api-reference/ai-detection This section demonstrates how to use the AI Detection API to analyze text. You can use either cURL for direct HTTP requests or the provided Python SDK. ```APIDOC ## Analyze Text with AI Detection API (v3) ### Description This endpoint analyzes the provided text to determine the proportion of AI-generated, AI-assisted, and human-written content. It returns a detailed breakdown, including confidence scores and segment analysis. ### Method POST ### Endpoint https://text.api.pangram.com/v3 ### Parameters #### Request Body - **text** (string) - Required - The text content to be analyzed. ### Request Example ```json { "text": "The text to analyze with V3 classification" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **version** (string) - The API version used. - **headline** (string) - A summary headline of the detection result. - **prediction** (string) - A detailed prediction of the content's origin. - **prediction_short** (string) - A short, categorical prediction (e.g., "Mixed"). - **fraction_ai** (number) - The estimated fraction of AI-generated content. - **fraction_ai_assisted** (number) - The estimated fraction of AI-assisted content. - **fraction_human** (number) - The estimated fraction of human-written content. - **num_ai_segments** (integer) - The number of detected AI-generated segments. - **num_ai_assisted_segments** (integer) - The number of detected AI-assisted segments. - **num_human_segments** (integer) - The number of detected human-written segments. - **windows** (array) - An array of objects, each representing a segment of the text with its analysis. - **text** (string) - The text content of the segment. - **label** (string) - The classification label for the segment (e.g., "AI-Generated"). - **ai_assistance_score** (number) - The score indicating the level of AI assistance. - **confidence** (string) - The confidence level of the segment's classification. - **start_index** (integer) - The starting character index of the segment in the original text. - **end_index** (integer) - The ending character index of the segment in the original text. - **word_count** (integer) - The number of words in the segment. - **token_length** (integer) - The number of tokens in the segment. ### Response Example ```json { "text": "The text to analyze with V3 classification", "version": "3.0", "headline": "AI Detected", "prediction": "We are confident that this document is a mix of AI-generated, AI-assisted, and human-written content", "prediction_short": "Mixed", "fraction_ai": 0.70, "fraction_ai_assisted": 0.20, "fraction_human": 0.10, "num_ai_segments": 7, "num_ai_assisted_segments": 2, "num_human_segments": 1, "windows": [ { "text": "The text to analyze", "label": "AI-Generated", "ai_assistance_score": 0.85, "confidence": "High", "start_index": 0, "end_index": 19, "word_count": 4, "token_length": 5 }, { "text": "with V3 classification", "label": "Moderately AI-Assisted", "ai_assistance_score": 0.45, "confidence": "Medium", "start_index": 20, "end_index": 49, "word_count": 4, "token_length": 5 } ] } ``` ``` -------------------------------- ### Classify Text with POST / Source: https://docs.pangram.com/api-reference/deprecated-endpoints Use this endpoint to classify input text and receive a link to a dashboard page with detailed results. The request body requires the text to be classified. ```http POST https://dashboard-text.api.pangram.com ``` -------------------------------- ### Authenticate API Request with JavaScript Source: https://docs.pangram.com/api-reference/introduction This JavaScript snippet shows how to authenticate API requests using the fetch API. Pass your API key in the x-api-key header and set the Content-Type to application/json. ```javascript const response = await fetch("https://text.api.pangram.com/v3", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": "" }, body: JSON.stringify({ text: "Your text here" }) }); ``` -------------------------------- ### Check Plagiarism with Python Source: https://docs.pangram.com/api-reference/plagiarism-detection Utilize the Pangram Python client to check text for plagiarism. Instantiate the client and call the `check_plagiarism` method with the text you want to analyze. ```python from pangram import Pangram pangram_client = Pangram() result = pangram_client.check_plagiarism("The text to check for plagiarism") ``` -------------------------------- ### Batch Endpoint Source: https://docs.pangram.com/api-reference/deprecated-endpoints Legacy endpoint for classifying multiple texts in a single request. ```APIDOC ## POST / ### Description Classify multiple texts in a single request. ### Method POST ### Endpoint https://text-batch.api.pangram.com ### Parameters #### Request Body - **text** (array) - Required - An array of input texts to classify. ### Response #### Success Response (200) - **responses** (array) - The classification results as a list. Each item contains `text`, `ai_likelihood`, and `prediction`. ### Request Example ```json { "text": [ "The first text to analyze", "The second text to analyze" ] } ``` ### Response Example ```json { "responses": [ { "text": "The first text to analyze", "prediction": "Likely AI", "ai_likelihood": 0.92 }, { "text": "The second text to analyze", "prediction": "Possibly AI", "ai_likelihood": 0.58 } ] } ``` ``` -------------------------------- ### POST / Source: https://docs.pangram.com/api-reference/deprecated-endpoints Classifies text and returns a link to a dashboard page with the full result. This endpoint is deprecated and will be removed in April 2026. ```APIDOC ## POST / ### Description Classify text and return a link to a dashboard page with the full result. ### Method POST ### Endpoint https://dashboard-text.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The input text to classify. ### Response #### Success Response (200) - **ai_likelihood** (float) - Classification score from 0.0 (human) to 1.0 (AI). - **prediction** (string) - A string representing the classification. - **short_prediction** (string) - Short classification string (`"AI"`, `"Human"`, `"Mixed"`). - **dashboard_link** (string) - A link to the dashboard page containing the full classification result. - **fraction_ai_content** (float) - Fraction of windows classified as AI. - **max_ai_likelihood** (float) - Maximum AI likelihood score among all windows. - **avg_ai_likelihood** (float) - Average AI likelihood score among all windows. - **windows** (array) - List of windows and their individual classifications. ### Request Example ```json { "text": "Extremely long text." } ``` ### Response Example ```json { "text": "Extremely long text.", "prediction": "Highly likely AI", "ai_likelihood": 1.0, "dashboard_link": "https://www.pangram.com/history/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "max_ai_likelihood": 1.0, "avg_ai_likelihood": 0.6, "fraction_ai_content": 0.5, "windows": [ { "text": "Extremely long", "ai_likelihood": 1.0, "prediction": "Highly likely AI" }, { "text": "long text.", "ai_likelihood": 0.2, "prediction": "Unlikely AI" } ] } ``` ``` -------------------------------- ### Generate Public Dashboard Link with cURL Source: https://docs.pangram.com/quickstart-rest Include `"public_dashboard_link": true` in your request to obtain a shareable link to the analysis results. The response will contain a `dashboard_link` field. ```bash curl -X POST https://text.api.pangram.com/v3 \ -H "Content-Type: application/json" \ -H "x-api-key: $PANGRAM_API_KEY" \ -d '{ "text": "The text to analyze", "public_dashboard_link": true }' ``` -------------------------------- ### Check for plagiarism with cURL Source: https://docs.pangram.com/quickstart-rest Use this endpoint to check text against a database of online content. Note the different base URL (`plagiarism.api.pangram.com`). ```bash curl -X POST https://plagiarism.api.pangram.com \ -H "Content-Type: application/json" \ -H "x-api-key: $PANGRAM_API_KEY" \ -d '{ "text": "Text to check for plagiarism" }' ``` -------------------------------- ### Check for plagiarism with Pangram Source: https://docs.pangram.com/quickstart Utilize the `check_plagiarism` method to scan text against a database of online content. The response indicates if plagiarism is detected, provides source URLs, and details about matched content. ```python 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']}") ``` -------------------------------- ### Check Text for Plagiarism Source: https://docs.pangram.com/sdk/python Use this method to check a given text for potential plagiarism against online content. It requires the text to be provided as a string parameter. ```python result = client.check_plagiarism(text) ``` -------------------------------- ### predict_short() Source: https://docs.pangram.com/sdk/python Classifies text using a simplified endpoint that truncates input to 512 tokens. ```APIDOC ## predict_short() Classify text using the short endpoint. Cuts off text at 512 tokens. ```python 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. ``` -------------------------------- ### Detect AI-generated text (V3) Source: https://docs.pangram.com/quickstart-rest Returns detailed analysis with AI-assistance detection and segment-level metrics for the provided text. ```APIDOC ## POST https://text.api.pangram.com/v3 ### Description Analyzes text to detect AI-generated content, providing detailed metrics and segment-level analysis. ### Method POST ### Endpoint https://text.api.pangram.com/v3 ### Parameters #### Request Body - **text** (string) - Required - The text content to analyze. - **public_dashboard_link** (boolean) - Optional - If true, a shareable link to the results will be included in the response. ### Request Example ```json { "text": "The text to analyze", "public_dashboard_link": true } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **version** (string) - The API version used. - **headline** (string) - A summary classification of the text's authorship (e.g., "AI Detected"). - **prediction** (string) - A detailed prediction of the text's authorship. - **prediction_short** (string) - A short version of the prediction. - **fraction_ai** (number) - The fraction of the text identified as AI-generated. - **fraction_ai_assisted** (number) - The fraction of the text identified as AI-assisted. - **fraction_human** (number) - The fraction of the text identified as human-written. - **num_ai_segments** (integer) - The number of segments classified as AI-generated. - **num_ai_assisted_segments** (integer) - The number of segments classified as AI-assisted. - **num_human_segments** (integer) - The number of segments classified as human-written. - **windows** (array) - An array of segment-level classifications. - **text** (string) - The text segment. - **label** (string) - The classification label for the segment. - **ai_assistance_score** (number) - The AI assistance score for the segment. - **confidence** (string) - The confidence level of the classification. - **start_index** (integer) - The starting index of the segment in the original text. - **end_index** (integer) - The ending index of the segment in the original text. - **word_count** (integer) - The word count of the segment. - **token_length** (integer) - The token length of the segment. - **dashboard_link** (string) - A shareable URL to the results dashboard (only present if `public_dashboard_link` is true). ### Response Example ```json { "text": "The text to analyze", "version": "3.0", "headline": "AI Detected", "prediction": "We are confident that this document is a mix of AI-generated, AI-assisted, and human-written content", "prediction_short": "Mixed", "fraction_ai": 0.70, "fraction_ai_assisted": 0.20, "fraction_human": 0.10, "num_ai_segments": 7, "num_ai_assisted_segments": 2, "num_human_segments": 1, "windows": [ { "text": "The text to analyze", "label": "AI-Generated", "ai_assistance_score": 0.85, "confidence": "High", "start_index": 0, "end_index": 19, "word_count": 4, "token_length": 5 } ] } ``` ``` -------------------------------- ### Extended Prediction (Deprecated) Source: https://docs.pangram.com/sdk/python This method for extended analysis is deprecated and will be removed. Use `predict()` instead. It takes the text to analyze as input. ```python result = client.predict_extended(text) ``` -------------------------------- ### POST / Extended Analysis Source: https://docs.pangram.com/api-reference/deprecated-endpoints Performs extended text analysis with adaptive boundaries and windowed results. Use this endpoint for detailed classification of text, including AI likelihood scores and predictions. The response includes segmented analysis of the input text. ```json { "text": "The text to analyze with extended classification", "avg_ai_likelihood": 0.75, "max_ai_likelihood": 0.92, "prediction": "Primarily AI-generated, or heavily AI-assisted", "prediction_short": "AI", "headline": "AI Detected", "windows": [ { "text": "The text to analyze", "ai_likelihood": 0.85, "label": "AI", "confidence": "Medium", "start_index": 0, "end_index": 19, "word_count": 4 }, { "text": "with extended classification", "ai_likelihood": 0.65, "label": "AI", "confidence": "Low", "start_index": 20, "end_index": 47, "word_count": 3 } ], "window_likelihoods": [0.85, 0.65], "window_indices": [[0, 19], [20, 47]], "fraction_human": 0.25, "fraction_ai": 0.70, "fraction_mixed": 0.05, "metadata": { "request_id": "123e4567-e89b-12d3-a456-426614174000" }, "version": "adaptive_boundaries", "dashboard_link": "https://www.pangram.com/history/123e4567-e89b-12d3-a456-426614174000" } ``` -------------------------------- ### Sliding Window Endpoint Source: https://docs.pangram.com/api-reference/deprecated-endpoints Legacy endpoint for classifying a long document using a sliding window across the full text. ```APIDOC ## POST / ### Description Classify a long document using a sliding window across the full text. ### Method POST ### Endpoint https://text-sliding.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The input text to segment into windows and classify. - **return_ai_sentences** (boolean) - Optional - If `true`, return a list of the most indicative AI sentences. Defaults to `false`. ### Response #### Success Response (200) - **text** (string) - The classified text. - **ai_likelihood** (float) - Classification score from 0.0 (human) to 1.0 (AI). - **max_ai_likelihood** (float) - Maximum AI likelihood score among all windows. - **avg_ai_likelihood** (float) - Average AI likelihood score among all windows. - **prediction** (string) - A string representing the classification. - **short_prediction** (string) - Short classification string (`"AI"`, `"Human"`, `"Mixed"`). - **fraction_ai_content** (float) - Fraction of windows classified as AI. - **windows** (array) - List of windows and their individual classifications. ### Request Example ```json { "text": "Extremely long text.", "return_ai_sentences": true } ``` ### Response Example ```json { "text": "Extremely long text.", "prediction": "Highly likely AI", "ai_likelihood": 1.0, "max_ai_likelihood": 1.0, "avg_ai_likelihood": 0.6, "fraction_ai_content": 0.5, "windows": [ { "text": "Extremely long", "ai_likelihood": 1.0, "prediction": "Highly likely AI" }, { "text": "long text.", "ai_likelihood": 0.2, "prediction": "Unlikely AI" } ] } ``` ``` -------------------------------- ### POST / - Single Text Classification Source: https://docs.pangram.com/api-reference/deprecated-endpoints Use this endpoint for single text classification. It returns an AI likelihood score and optionally a list of indicative AI sentences. The request body requires the text to classify. ```http POST https://text.api.pangram.com ``` ```json { "text": "The text to analyze", "prediction": "Likely AI", "ai_likelihood": 0.92 } ``` -------------------------------- ### Classify Text with Short Endpoint Source: https://docs.pangram.com/sdk/python Use the predict_short() method for a quick classification of text, which cuts off input at 512 tokens. This method returns a classification score and a prediction string. ```python result = client.predict_short(text) ``` -------------------------------- ### check_plagiarism() Source: https://docs.pangram.com/sdk/python Checks the provided text for potential plagiarism against an online content database. It returns a detailed analysis of the plagiarism findings. ```APIDOC ## check_plagiarism() ### Description Check text for potential plagiarism against a database of online content. ### Method Signature `client.check_plagiarism(text: str)` ### Parameters #### Body Parameters - **text** (string) - Required - The text to check for plagiarism. ### Returns A dictionary containing 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. ``` -------------------------------- ### Classify Text with V3 API Source: https://docs.pangram.com/sdk/python Use the predict() method to classify text using the V3 API, obtaining detailed analysis including segment-level results. Set public_dashboard_link to True to include a link in the response. ```python result = client.predict(text, public_dashboard_link=False) ``` -------------------------------- ### Detect AI-generated text with Pangram Source: https://docs.pangram.com/quickstart Use the `predict` method for detailed AI-assistance detection and segment-level metrics. For a shorter prediction, use `predict_short` which truncates text at 512 tokens. ```python 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'] ``` ```python 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'] ``` -------------------------------- ### POST / - Batch Text Classification Source: https://docs.pangram.com/api-reference/deprecated-endpoints Classify multiple texts in a single request using this batch endpoint. The request body must be an array of texts. The response contains an array of classification results. ```http POST https://text-batch.api.pangram.com ``` ```json { "responses": [ { "text": "The first text to analyze", "prediction": "Likely AI", "ai_likelihood": 0.92 }, { "text": "The second text to analyze", "prediction": "Possibly AI", "ai_likelihood": 0.58 } ] } ``` -------------------------------- ### Check for plagiarism Source: https://docs.pangram.com/quickstart-rest Checks provided text against a database of online content to detect plagiarism. ```APIDOC ## POST https://plagiarism.api.pangram.com ### Description Compares the input text against a database of online content to identify potential plagiarism. ### Method POST ### Endpoint https://plagiarism.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The text content to check for plagiarism. ### Request Example ```json { "text": "Text to check for plagiarism" } ``` ### Response #### Success Response (200) - **text** (string) - The original text analyzed. - **plagiarism_detected** (boolean) - Indicates whether plagiarism was detected. - **plagiarized_content** (array) - A list of detected plagiarized content. - **source_url** (string) - The URL of the source where plagiarism was detected. - **matched_text** (string) - The portion of text that matches the source. - **similarity_score** (number) - The similarity score between the matched text and the source. - **total_sentences** (integer) - The total number of sentences in the input text. - **plagiarized_sentences** (integer) - The number of sentences identified as plagiarized. - **percent_plagiarized** (number) - The percentage of the text identified as plagiarized. ### Response Example ```json { "text": "Text to check for plagiarism", "plagiarism_detected": true, "plagiarized_content": [ { "source_url": "https://example.com/source", "matched_text": "Text to check for plagiarism", "similarity_score": 0.95 } ], "total_sentences": 1, "plagiarized_sentences": 1, "percent_plagiarized": 100.0 } ``` ``` -------------------------------- ### Root Endpoint Source: https://docs.pangram.com/api-reference/deprecated-endpoints Legacy endpoint for single text classification. Returns an AI likelihood score. ```APIDOC ## POST / ### Description Single text classification returning an AI likelihood score. ### Method POST ### Endpoint https://text.api.pangram.com ### Parameters #### Request Body - **text** (string) - Required - The input text to classify. - **return_ai_sentences** (boolean) - Optional - If `true`, return a list of the most indicative AI sentences. Defaults to `false`. ### Response #### Success Response (200) - **ai_likelihood** (float) - Classification score from 0.0 (human) to 1.0 (AI). - **text** (string) - The classified text. - **prediction** (string) - A string representing the classification. - **ai_sentences** (array) - List of the most indicative AI sentences. Only present when `return_ai_sentences` is `true`. ### Request Example ```json { "text": "The input text to classify", "return_ai_sentences": true } ``` ### Response Example ```json { "text": "The text to analyze", "prediction": "Likely AI", "ai_likelihood": 0.92, "ai_sentences": ["Indicative sentence 1", "Indicative sentence 2"] } ``` ``` -------------------------------- ### predict() Source: https://docs.pangram.com/sdk/python Classifies text using the V3 API, returning analysis with windowed, segment-level results. Supports an option to include a public dashboard link. ```APIDOC ## predict() Classify text as AI-generated, AI-assisted, or human-written using the V3 API. Returns analysis with windowed, segment-level results. ```python result = client.predict(text, public_dashboard_link=False) ``` ### Parameters * **text** (string) - Required - The text to be classified. * **public_dashboard_link** (boolean) - Optional, defaults to `false` - 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** (string) - Dashboard link. Only present when `public_dashboard_link` is `True`. * **windows** (list) - List of text windows and their classifications. Each window contains: * **text** (string) - The window text. * **label** (string) - Classification label (e.g., `"AI-Generated"`, `"Moderately AI-Assisted"`). * **ai_assistance_score** (float) - AI assistance score (0.0–1.0), where 0 means no AI assistance and 1.0 means AI-generated. * **confidence** (string) - Confidence level (`"High"`, `"Medium"`, `"Low"`). * **start_index** (integer) - Starting character index in the original text. * **end_index** (integer) - Ending character index in the original text. * **word_count** (integer) - Number of words in the window. * **token_length** (integer) - Token length of the window. Raises `ValueError` if the API returns an error. ```