Get started
Before you begin
Before you start, ensure you have the following:- An active Copyleaks account. If you don’t have one, sign up for free.
- You can find your API key on the API Dashboard.
Installation
Install the relevant packages usingpip install -U PyMuPDF Pillow copyleaks.Login
To perform a scan, we first need to generate an access token. For that, we will use the login endpoint. The API key can be found on the Copyleaks API Dashboard.Upon successful authentication, you will receive a token that must be attached to subsequent API calls via theAuthorization: Bearer <TOKEN> header.
This token remains valid for 48 hours.Response
Save this token. It is valid for 48 hours and can be reused for subsequent API calls.
Extracting images from a PDF file
Next, we are going to extract all the images from the PDF. The function below will take a pdf file path and extract all its images to a specified directory.The following example takes the input PDF file and outputs all its nested images to theoutput_folder directorySubmit for analysis
Once we have the extracted images, you can submit them for analysis.We are going to use the AI Image Detector Endpoint to send an image for analysis.AI Detection scan
This function takes your image, converts it to base64, and submits it via the SDK’sImageDetectionClient. The SDK handles authentication and HTTP transport.Interpreting the response
See the Interpreting The Response page on Detecting AI-Generated ImagesSummary
You have successfully submitted images from PDF for AI detection. You are free to adapt this code to your needs.Next steps
API Reference
Explore the full API reference for the AI Image Detection endpoint.
AI Image Detector Response
Explore the full response for the AI Image Detection.
Accuracy & 3rd Party Evaluations
Discover how Copyleaks AI Detector maintains top accuracy in third-party evaluations.

