SDK & Libraries
Use the SALZ API from JavaScript, Python, curl, or any HTTP client. No SDK required -- just standard REST calls.
SALZ is a standard REST API. You do not need an SDK -- any HTTP client in any language works. Below are ready-to-use examples for the most common languages and tools.
JavaScript / TypeScript
Using the built-in fetch API (Node.js 18+, Deno, Bun, or any modern browser):
async function optimizeText(text) {
const response = await fetch('https://add-salz.io/api/v1/optimize', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SALZ_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ text }),
});
if (!response.ok) {
throw new Error(`SALZ API error: ${response.status}`);
}
const data = await response.json();
return data.optimized;
}
const result = await optimizeText('Your AI-generated text here...');
console.log(result);
Python
Using the requests library:
import os
import requests
def optimize_text(text: str) -> str:
response = requests.post(
"https://add-salz.io/api/v1/optimize",
headers={
"Authorization": f"Bearer {os.environ['SALZ_API_KEY']}",
"Content-Type": "application/json",
},
json={"text": text},
timeout=30,
)
response.raise_for_status()
return response.json()["optimized"]
result = optimize_text("Your AI-generated text here...")
print(result)
curl
For quick testing from the command line:
curl -X POST https://add-salz.io/api/v1/optimize \
-H "Authorization: Bearer $SALZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Your AI-generated text here..."}'
Go
Using the standard library:
payload := bytes.NewBuffer([]byte(`{"text": "Your AI-generated text here..."}`))
req, _ := http.NewRequest("POST", "https://add-salz.io/api/v1/optimize", payload)
req.Header.Set("Authorization", "Bearer "+os.Getenv("SALZ_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
PHP
Using curl:
$ch = curl_init('https://add-salz.io/api/v1/optimize');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SALZ_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['text' => 'Your AI-generated text here...']),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Best Practices
- Store your API key in environment variables. Never hard-code keys in source files.
- Set a timeout of at least 30 seconds. Longer texts take more time to process.
- Handle errors gracefully. Check the HTTP status code and the
successfield in the response body. - Retry on 5xx errors. Use exponential backoff with a maximum of 3 retries.