Python
- Content Generation
- Content Rephrasing
import requests
def generate_content(prompt, tone=None, writing_mode='default'):
"""
Generate content using StealthGPT API
Args:
prompt (str): The prompt for content generation
tone (str, optional): Standard, HighSchool, College, or PhD. Used when writing_mode is essay.
writing_mode (str, optional): default follows the prompt. essay writes an academic essay.
Returns:
str: Generated content
Note:
For premium long-form output, use POST /api/stealthify/agent instead.
See https://www.stealthgpt.ai docs: api-reference/stealth-agent/guide
"""
api_token = 'YOUR_API_TOKEN'
url = 'https://www.stealthgpt.ai/api/stealthify'
payload = {
'prompt': prompt,
'rephrase': False,
'writingMode': writing_mode,
'model': 'super'
}
if tone:
payload['tone'] = tone
# Set headers
headers = {
'api-token': api_token,
'Content-Type': 'application/json'
}
# Send request
response = requests.post(url, headers=headers, json=payload)
# Check for successful response
if response.status_code == 200:
return response.json()['result']
else:
raise Exception(f"Error {response.status_code}: {response.text}")
# Example usage
content = generate_content(
prompt="Explain the benefits of cloud computing for small businesses",
tone="College",
writing_mode="essay"
)
print(content)
import requests
def rephrase_content(text):
"""
Rephrase content using StealthGPT API
Args:
text (str): The text to rephrase. Send only the source text.
Returns:
str: Rephrased content
"""
api_token = 'YOUR_API_TOKEN'
url = 'https://www.stealthgpt.ai/api/stealthify'
payload = {
'prompt': text,
'rephrase': True,
'model': 'super'
}
# Set headers
headers = {
'api-token': api_token,
'Content-Type': 'application/json'
}
# Send request
response = requests.post(url, headers=headers, json=payload)
# Check for successful response
if response.status_code == 200:
return response.json()['result']
else:
raise Exception(f"Error {response.status_code}: {response.text}")
# Example usage
rephrased = rephrase_content(
"Artificial intelligence is transforming many industries by automating tasks that previously required human intelligence."
)
print(rephrased)
Node.js
- Content Generation
- Content Rephrasing
const axios = require('axios');
/**
* Generate content using StealthGPT API
*
* @param {string} prompt - The prompt for content generation
* @param {Object} options - Optional parameters
* @param {string} options.tone - Standard, HighSchool, College, or PhD. Used when writingMode is essay.
* @param {string} options.writingMode - default follows the prompt. essay writes an academic essay.
* @returns {Promise<string>} - Generated content
*
* Note: For premium long-form output, use POST /api/stealthify/agent instead.
* See: api-reference/stealth-agent/guide
*/
async function generateContent(prompt, options = {}) {
const apiToken = 'YOUR_API_TOKEN';
const url = 'https://www.stealthgpt.ai/api/stealthify';
// Prepare request payload
const payload = {
prompt,
rephrase: false,
model: 'super',
...options
};
try {
// Send request
const response = await axios.post(url, payload, {
headers: {
'api-token': apiToken,
'Content-Type': 'application/json'
}
});
return response.data.result;
} catch (error) {
if (error.response) {
throw new Error(`Error ${error.response.status}: ${JSON.stringify(error.response.data)}`);
} else {
throw error;
}
}
}
// Example usage
generateContent(
'Explain the benefits of cloud computing for small businesses',
{
tone: 'College',
writingMode: 'essay'
}
)
.then(content => console.log(content))
.catch(error => console.error(error));
const axios = require('axios');
/**
* Rephrase content using StealthGPT API
*
* @param {string} text - The source text to rephrase
* @returns {Promise<string>} - Rephrased content
*/
async function rephraseContent(text) {
const apiToken = 'YOUR_API_TOKEN';
const url = 'https://www.stealthgpt.ai/api/stealthify';
// Prepare request payload
const payload = {
prompt: text,
rephrase: true,
model: 'super'
};
try {
// Send request
const response = await axios.post(url, payload, {
headers: {
'api-token': apiToken,
'Content-Type': 'application/json'
}
});
return response.data.result;
} catch (error) {
if (error.response) {
throw new Error(`Error ${error.response.status}: ${JSON.stringify(error.response.data)}`);
} else {
throw error;
}
}
}
// Example usage
rephraseContent(
'Artificial intelligence is transforming many industries by automating tasks that previously required human intelligence.'
)
.then(content => console.log(content))
.catch(error => console.error(error));
Ruby
- Content Generation
- Content Rephrasing
require 'net/http'
require 'uri'
require 'json'
def generate_content(prompt, tone: nil, writing_mode: "default")
api_token = 'YOUR_API_TOKEN'
url = URI.parse('https://www.stealthgpt.ai/api/stealthify')
payload = {
prompt: prompt,
rephrase: false,
writingMode: writing_mode,
model: "super"
}
payload[:tone] = tone if tone
# Set up the HTTP request
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url.path)
request['api-token'] = api_token
request['Content-Type'] = 'application/json'
request.body = payload.to_json
# Send the request
response = http.request(request)
# Check for successful response
if response.code == '200'
return JSON.parse(response.body)['result']
else
raise "Error #{response.code}: #{response.body}"
end
end
# Example usage
content = generate_content(
"Explain the benefits of cloud computing for small businesses",
tone: "College",
writing_mode: "essay"
)
puts content
require 'net/http'
require 'uri'
require 'json'
def rephrase_content(text)
api_token = 'YOUR_API_TOKEN'
url = URI.parse('https://www.stealthgpt.ai/api/stealthify')
payload = {
prompt: text,
rephrase: true,
model: "super"
}
# Set up the HTTP request
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url.path)
request['api-token'] = api_token
request['Content-Type'] = 'application/json'
request.body = payload.to_json
# Send the request
response = http.request(request)
# Check for successful response
if response.code == '200'
return JSON.parse(response.body)['result']
else
raise "Error #{response.code}: #{response.body}"
end
end
# Example usage
rephrased = rephrase_content(
"Artificial intelligence is transforming many industries by automating tasks that previously required human intelligence."
)
puts rephrased