Ensure Content Authenticity with AI Detection Actions

26 Apr 2025
Ensure Content Authenticity with AI Detection Actions

In an age where content generation is increasingly automated, ensuring the authenticity of text has become crucial. The "Detect AI Content" service provides developers with powerful Cognitive Actions that leverage advanced AI algorithms to identify whether text is generated by a machine or written by a human. By integrating these actions into your applications, you can enhance content verification processes, maintain quality control, and foster trust with your users.

This service is particularly beneficial for a variety of use cases, including content moderation, academic integrity checks, and enhancing user-generated content platforms. With the ability to quickly discern the source of text, developers can streamline their workflows and improve the overall quality of digital content.

Prerequisites

To get started with the "Detect AI Content" service, you will need an API key for the Cognitive Actions and a basic understanding of how to make API calls.

Detect AI-Generated Content

The "Detect AI-Generated Content" action utilizes the AI-HUMAN Detector model, which is designed to differentiate between AI-generated and human-generated text. This capability is essential for verifying the authenticity of content and ensuring that users receive high-quality information.

Input Requirements

The input for this action requires a JSON object that contains the content to be analyzed. The key properties include:

  • content (string): The text you wish to process. For example, it could be a full article, a paragraph, or a single sentence.
  • contentType (string, optional): Specifies the type of content to analyze, with options such as 'all' for the entire text, 'paragraphs' for individual paragraphs, or 'sentences' for each sentence. The default setting is 'all'.

Example input:

{
  "content": "Welcome, and thanks for your support...",
  "contentType": "all"
}

Expected Output

The output will provide a total score indicating the likelihood that the content is AI-generated. A score closer to 1 suggests a higher probability that the text is machine-generated, while a score closer to 0 indicates human authorship.

Example output:

{
  "totalScore": 0.9995
}

Use Cases for this Action

  • Content Moderation: Implement this action to automatically screen user-generated content on platforms, ensuring that submissions are authentic and not AI-generated spam.
  • Academic Integrity: Use it to check student submissions in educational institutions, helping to uphold academic standards and prevent plagiarism.
  • Quality Control: Businesses can utilize this action to ensure that marketing materials, blog posts, and customer communications maintain a human touch and authenticity.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "76dabcc1-9027-4e65-b241-9a74f831f1bb" # Action ID for: Detect AI-Generated Content

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "content": "Welcome, and thanks for your support\n\nGasbyAI is an AI-powered chatbot that allows you to get questions in different areas and industries.\n\nGasbyAI relies on an API Service to run. You can connect to OpenAI, Azure OpenAI, Gasby OpenAI, Claude, OpenRouter, or customized service API. Please note that you don't need a ChatGPT account to run GasbyAI.\n\nTo get started, make sure you have connected to your API service.\n\nGasbyAI is under active development. Updates are announced bi-weekly on Discord, and available on our changelog. In case you have any questions or feedback, please drop a message on Gasby's Discord channel, or email hieunc(at)gasbyai.com"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

The "Detect AI Content" service offers developers robust tools to verify the authenticity of text, ensuring quality and trust in digital communications. By integrating the "Detect AI-Generated Content" action, you can effectively address challenges related to content authenticity in various applications, from social media to educational platforms.

As you explore the possibilities of this service, consider the next steps for integrating these actions into your projects, enhancing the way you engage with content and your users.