Python Example
import requests
import os
# Initialize API client
api_key = os.getenv('AIHUMANIZER_API_KEY')
base_url = 'https://api.aihumanizerapi.com'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
# Single text humanization
def humanize_text(text, language='en', intensity='medium'):
endpoint = f'{base_url}/v1/humanize'
payload = {
'text': text,
'language': language,
'intensity': intensity,
'preserve_formatting': True,
'tone': 'professional'
}
response = requests.post(endpoint, headers=headers, json=payload)
if response.status_code == 200:
result = response.json()
return result['humanized_text']
else:
print(f'Error: {response.status_code}')
print(response.json())
return None
# Batch humanization
def humanize_batch(items, language='en', intensity='medium'):
endpoint = f'{base_url}/v1/humanize/batch'
payload = {
'items': items,
'language': language,
'intensity': intensity
}
response = requests.post(endpoint, headers=headers, json=payload)
if response.status_code == 200:
return response.json()
else:
print(f'Error: {response.status_code}')
return None
# Get usage statistics
def get_usage():
endpoint = f'{base_url}/v1/usage'
response = requests.get(endpoint, headers=headers)
if response.status_code == 200:
return response.json()
else:
return None
# Example usage
if __name__ == '__main__':
# Single text example
original_text = "The artificial intelligence system processes data using advanced algorithms."
humanized = humanize_text(original_text)
print(f"Original: {original_text}")
print(f"Humanized: {humanized}")
# Batch example
batch_items = [
{'id': '1', 'text': 'Machine learning models require substantial computational resources.'},
{'id': '2', 'text': 'Neural networks have demonstrated remarkable performance across diverse tasks.'}
]
batch_result = humanize_batch(batch_items)
print(f"\nBatch Results: {batch_result}")
# Check usage
usage = get_usage()
print(f"\nUsage: {usage}")
Node.js Example
const axios = require('axios');
// Initialize API client
const apiKey = process.env.AIHUMANIZER_API_KEY;
const baseUrl = 'https://api.aihumanizerapi.com';
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
};
// Single text humanization
async function humanizeText(text, language = 'en', intensity = 'medium') {
try {
const response = await axios.post(`${baseUrl}/v1/humanize`, {
text: text,
language: language,
intensity: intensity,
preserve_formatting: true,
tone: 'professional'
}, { headers });
return response.data.humanized_text;
} catch (error) {
console.error('Error:', error.response?.status, error.response?.data);
return null;
}
}
// Batch humanization
async function humanizeBatch(items, language = 'en', intensity = 'medium') {
try {
const response = await axios.post(`${baseUrl}/v1/humanize/batch`, {
items: items,
language: language,
intensity: intensity
}, { headers });
return response.data;
} catch (error) {
console.error('Error:', error.response?.status, error.response?.data);
return null;
}
}
// Get usage statistics
async function getUsage() {
try {
const response = await axios.get(`${baseUrl}/v1/usage`, { headers });
return response.data;
} catch (error) {
console.error('Error:', error.response?.status, error.response?.data);
return null;
}
}
// Example usage
(async () => {
// Single text example
const originalText = 'The artificial intelligence system processes data using advanced algorithms.';
const humanized = await humanizeText(originalText);
console.log(`Original: ${originalText}`);
console.log(`Humanized: ${humanized}`);
// Batch example
const batchItems = [
{ id: '1', text: 'Machine learning models require substantial computational resources.' },
{ id: '2', text: 'Neural networks have demonstrated remarkable performance across diverse tasks.' }
];
const batchResult = await humanizeBatch(batchItems);
console.log(`\nBatch Results:`, batchResult);
// Check usage
const usage = await getUsage();
console.log(`\nUsage:`, usage);
})();
PHP Example
<?php
class AIHumanizerAPI {
private $apiKey;
private $baseUrl = 'https://api.aihumanizerapi.com';
public function __construct($apiKey) {
$this->apiKey = $apiKey;
}
private function makeRequest($method, $endpoint, $data = null) {
$url = $this->baseUrl . $endpoint;
$headers = [
'Authorization: Bearer ' . $this->apiKey,
'Content-Type: application/json'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'status' => $httpCode,
'data' => json_decode($response, true)
];
}
public function humanizeText($text, $language = 'en', $intensity = 'medium') {
$data = [
'text' => $text,
'language' => $language,
'intensity' => $intensity,
'preserve_formatting' => true,
'tone' => 'professional'
];
$response = $this->makeRequest('POST', '/v1/humanize', $data);
if ($response['status'] === 200) {
return $response['data']['humanized_text'];
}
throw new Exception('API Error: ' . $response['status']);
}
public function humanizeBatch($items, $language = 'en', $intensity = 'medium') {
$data = [
'items' => $items,
'language' => $language,
'intensity' => $intensity
];
$response = $this->makeRequest('POST', '/v1/humanize/batch', $data);
if ($response['status'] === 200) {
return $response['data'];
}
throw new Exception('API Error: ' . $response['status']);
}
public function getUsage() {
$response = $this->makeRequest('GET', '/v1/usage');
if ($response['status'] === 200) {
return $response['data'];
}
throw new Exception('API Error: ' . $response['status']);
}
}
// Example usage
try {
$apiKey = getenv('AIHUMANIZER_API_KEY');
$client = new AIHumanizerAPI($apiKey);
// Single text example
$originalText = 'The artificial intelligence system processes data using advanced algorithms.';
$humanized = $client->humanizeText($originalText);
echo "Original: $originalText\n";
echo "Humanized: $humanized\n\n";
// Batch example
$batchItems = [
['id' => '1', 'text' => 'Machine learning models require substantial computational resources.'],
['id' => '2', 'text' => 'Neural networks have demonstrated remarkable performance across diverse tasks.']
];
$batchResult = $client->humanizeBatch($batchItems);
echo "Batch Results:\n";
echo json_encode($batchResult, JSON_PRETTY_PRINT) . "\n\n";
// Check usage
$usage = $client->getUsage();
echo "Usage:\n";
echo json_encode($usage, JSON_PRETTY_PRINT) . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
cURL Example
# Set your API key
API_KEY="your-api-key-here"
BASE_URL="https://api.aihumanizerapi.com"
# Single text humanization
curl -X POST $BASE_URL/v1/humanize \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "The artificial intelligence system processes data using advanced algorithms.",
"language": "en",
"intensity": "medium",
"preserve_formatting": true,
"tone": "professional"
}'
# Batch humanization
curl -X POST $BASE_URL/v1/humanize/batch \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"id": "1",
"text": "Machine learning models require substantial computational resources."
},
{
"id": "2",
"text": "Neural networks have demonstrated remarkable performance across diverse tasks."
}
],
"language": "en",
"intensity": "medium"
}'
# Get supported languages
curl -X GET $BASE_URL/v1/languages \
-H "Authorization: Bearer $API_KEY"
# Check usage statistics
curl -X GET $BASE_URL/v1/usage \
-H "Authorization: Bearer $API_KEY"