gptzero_detect
Analyze text to detect AI-generated content and get probability scores for AI, human, or mixed authorship with multilingual support.
Instructions
Detect if text was generated by AI. Returns probability scores for AI, human, and mixed content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document | Yes | The text document you want to analyze for AI detection | |
| multilingual | No | Enable multilingual detection (supports French and Spanish) |
Implementation Reference
- src/index.ts:104-136 (handler)Handler function for the gptzero_detect tool. Parses input arguments using DetectTextSchema, calls GPTZeroClient.detectText, extracts key metrics, and returns formatted text response with AI detection results.case "gptzero_detect": { const { document, multilingual } = DetectTextSchema.parse(args); const result = await client.detectText(document, multilingual); // Extract key metrics from the first document const doc = result.documents[0]; const summary = { predicted_class: doc.predicted_class, confidence: doc.confidence_category, probabilities: doc.class_probabilities, result_message: doc.result_message, average_generated_prob: doc.average_generated_prob, completely_generated_prob: doc.completely_generated_prob, }; return { content: [ { type: "text", text: `AI Detection Result:\n\n` + `Prediction: ${summary.predicted_class}\n` + `Confidence: ${summary.confidence}\n` + `Message: ${summary.result_message}\n\n` + `Probabilities:\n` + `- AI: ${(summary.probabilities.ai * 100).toFixed(1)}%\n` + `- Human: ${(summary.probabilities.human * 100).toFixed(1)}%\n` + `- Mixed: ${(summary.probabilities.mixed * 100).toFixed(1)}%\n\n` + `Full analysis:\n${JSON.stringify(result, null, 2)}`, }, ], }; }
- src/index.ts:69-87 (registration)Registration of the gptzero_detect tool in the ListTools response, including name, description, and input schema definition.{ name: "gptzero_detect", description: "Detect if text was generated by AI. Returns probability scores for AI, human, and mixed content.", inputSchema: { type: "object", properties: { document: { type: "string", description: "The text document you want to analyze for AI detection", }, multilingual: { type: "boolean", description: "Enable multilingual detection (supports French and Spanish)", default: false, }, }, required: ["document"], }, },
- src/index.ts:51-54 (schema)Zod schema validator for gptzero_detect input parameters, used in the handler to parse and validate arguments.const DetectTextSchema = z.object({ document: z.string().describe("The text document you want to analyze for AI detection"), multilingual: z.boolean().optional().default(false).describe("Enable multilingual detection (supports French and Spanish)"), });
- src/index.ts:24-49 (helper)GPTZeroClient class providing API client for GPTZero with detectText method that performs the core AI detection API call used by the gptzero_detect handler.class GPTZeroClient { private api: AxiosInstance; constructor(apiKey: string) { this.api = axios.create({ baseURL: "https://api.gptzero.me/v2", headers: { "x-api-key": apiKey, "Content-Type": "application/json", }, }); } async detectText(document: string, multilingual = false) { const response = await this.api.post("/predict/text", { document, multilingual, }); return response.data; } async getModelVersions() { const response = await this.api.get("/model-versions/ai-scan"); return response.data; } }